Visitar URL original
Record the creation of a drawing editor in the undo stack only once (#22270) by soujasK · Pull Request #22354 · mozilla/pdf.js · GitHub
Skip to content

Record the creation of a drawing editor in the undo stack only once (#22270) - #22354

Closed
soujasK wants to merge 1 commit into
mozilla:masterfrom
soujasK:fix/undo-editor-rerender
Closed

soujasK wants to merge 1 commit into
mozilla:masterfrom
soujasK:fix/undo-editor-rerender

Conversation

@soujasK

@soujasK soujasK commented Oct 27, 2026

Copy link
Copy Markdown

Fixes #22270.

When a page is rendered again, AnnotationEditorLayer.render() adds the page's editors back with add(), which calls onceAdded(). HighlightEditor and DrawingEditor (and so ink and signature editors) called addUndoableEditor() from onceAdded() every time, so each render pushed another undo step whose undo removes an editor created earlier. After scrolling a page out of the rendering buffer and back, undo removed an older annotation instead of reverting the last change.

This adds DrawingEditor._addToUndoStack(), which records the creation only the first time, as StampEditor already does with #hasBeenAddedInUndoStack. It's used by the highlight and drawing onceAdded() and by SignatureEditor.addSignature(), so a signature added through the dialog isn't recorded a second time when its page is rendered again.

The new integration test highlights a word on page 1 and another on page 14 (the last change), scrolls back so that page 1 is rendered again, and checks that undo removes the highlight on page 14. It follows the existing "Delete a highlight, scroll and undo it" test. I couldn't run the integration tests locally, so I'd appreciate a botio run; eslint and prettier pass on the changed files.

…22270)

When a page is rendered again, AnnotationEditorLayer.render() adds the
page's editors back, which calls onceAdded(). Highlight, ink and signature
editors recorded their creation every time, so each render pushed another
undo step that removes an editor created earlier, and undo no longer
reverted the last change.

Record the creation only the first time, like StampEditor already does.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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