Skip to content

Commit

Permalink
Merge pull request #17933 from Snuffleupagus/pr-17464-followup
Browse files Browse the repository at this point in the history
Fix resetting of cursor-tools when closing the document (PR 17464 follow-up)
  • Loading branch information
timvandermeij authored Apr 12, 2024
2 parents 2d885e2 + 60832fe commit e005e6e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
18 changes: 8 additions & 10 deletions web/pdf_cursor_tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,14 @@ class PDFCursorTools {

#addEventListeners() {
this.eventBus._on("switchcursortool", evt => {
this.switchTool(evt.tool);
if (!evt.reset) {
this.switchTool(evt.tool);
} else if (this.#prevActive !== null) {
annotationEditorMode = AnnotationEditorType.NONE;
presentationModeState = PresentationModeState.NORMAL;

enableActive();
}
});

let annotationEditorMode = AnnotationEditorType.NONE,
Expand All @@ -131,15 +138,6 @@ class PDFCursorTools {
}
};

this.eventBus._on("secondarytoolbarreset", evt => {
if (this.#prevActive !== null) {
annotationEditorMode = AnnotationEditorType.NONE;
presentationModeState = PresentationModeState.NORMAL;

enableActive();
}
});

this.eventBus._on("annotationeditormodechanged", ({ mode }) => {
annotationEditorMode = mode;

Expand Down
1 change: 1 addition & 0 deletions web/secondary_toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ class SecondaryToolbar {
this.#updateUIState();

// Reset the Scroll/Spread buttons too, since they're document specific.
this.eventBus.dispatch("switchcursortool", { source: this, reset: true });
this.#scrollModeChanged({ mode: ScrollMode.VERTICAL });
this.#spreadModeChanged({ mode: SpreadMode.NONE });
}
Expand Down

0 comments on commit e005e6e

Please sign in to comment.