Skip to content

Add drawing editors to the undo stack only once (issue 22270) - #22491

Open
yuyongyan29-dev wants to merge 2 commits into
mozilla:masterfrom
yuyongyan29-dev:fix/22270-undo-rerender
Open

yuyongyan29-dev wants to merge 2 commits into
mozilla:masterfrom
yuyongyan29-dev:fix/22270-undo-rerender

Conversation

@yuyongyan29-dev

Copy link
Copy Markdown

When a page is rendered again, its editors are added back and DrawingEditor.onceAdded() calls addUndoableEditor() again, so after scrolling a page out and back, Ctrl+Z undoes a stale "add" step and removes that drawing instead of the last edit.

Same approach as the closed #22354 by @soujasK: track whether the editor was already added and push the undo step only the first time. HighlightEditor.onceAdded() makes the same call, and SignatureEditor.addSignature() records the step itself, so both use the new helper too. Integration tests cover ink and highlight.

Fixes #22270

cursoragent and others added 2 commits November 9, 2026 18:16
onceAdded() runs again when a page is rendered, so a highlight, ink, or
signature pushed another undo step. Undo then removed that earlier editor
instead of the last edit.

Co-authored-by: Yuyongyan <yuyongyan29@gmail.com>
Both follow the existing tests that scroll a page out of the buffer:
create an editor on page 1 and another on page 14, render page 1 again,
and check that undo removes the later editor.

Co-authored-by: soujasK <121026960+soujasK@users.noreply.github.com>
Co-authored-by: Yuyongyan <yuyongyan29@gmail.com>

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: After a page is rendered again, undo removes an earlier highlight or drawing instead of the last edit

2 participants