Skip to content

fix(superdoc): expose header/footer edits in update callbacks#2368

Open
luccas-harbour wants to merge 5 commits intomainfrom
luccas/sd-2179-bug-headerfooter-edits-do-not-emit-update-events-until-blur
Open

fix(superdoc): expose header/footer edits in update callbacks#2368
luccas-harbour wants to merge 5 commits intomainfrom
luccas/sd-2179-bug-headerfooter-edits-do-not-emit-update-events-until-blur

Conversation

@luccas-harbour
Copy link
Contributor

Summary

This PR makes header and footer edits observable through the same public callback surface as body edits.

Before this change, typing in header/footer child editors updated internal state, but those edits were not propagated through the public onEditorUpdate and onTransaction hooks with the same immediacy as body edits. This caused integrations that rely on those callbacks for dirty-state tracking, autosave, and other live reactions to miss header/footer changes until blur.

What Changed

  • Forward live header/footer child-editor update and transaction events through the header/footer session flow.
  • Re-emit those events from PresentationEditor as header/footer-specific presentation events.
  • Bridge those presentation events into the existing SuperDoc public callback surface.
  • Normalize callback payloads so callers can tell where the change originated via:
    • sourceEditor
    • surface (body, header, or footer)
    • headerId
    • sectionType
  • Update the published SuperDoc and React wrapper event types to match the new payload shape.

Testing

  • Added a PresentationEditor test that verifies live header/footer child-editor updates and transactions are re-emitted immediately.
  • Added a SuperDoc.vue test that verifies header/footer presentation events are forwarded into editor-update and onTransaction.

@linear
Copy link

linear bot commented Mar 11, 2026

Copy link
Contributor

@caio-pizzol caio-pizzol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luccas-harbour clean approach, event listeners are set up and cleaned up in all the right places. no correctness blockers.

left three small inline comments — one consistency fix and two simplification ideas.

on tests: the happy path is covered well. three gaps worth considering: (1) no test that events stop firing after leaving header/footer mode, (2) no test for the body-editor path through the new payload builders, (3) footer surface isn't tested end-to-end (only header).

Copy link
Contributor

@caio-pizzol caio-pizzol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luccas-harbour all three items from last round are fixed, nice. tests look good too — all the gaps are covered now.

left two small comments, nothing blocking.

};
};

const buildEditorUpdatePayload = (payload = {}) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buildEditorUpdatePayload just passes through to buildEditorPayloadBase without adding anything — could skip the wrapper and call the base directly. worth it?

boundingSpy.mockRestore();
});

it('re-emits live header/footer child editor updates and transactions', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same ~25 lines of setup (create editor, wait for layout, mock viewport, add spies) are copied across all three new tests. a small helper would make these easier to read.

Copy link
Collaborator

@harbournick harbournick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants