diff --git a/src/display/editor/annotation_editor_layer.js b/src/display/editor/annotation_editor_layer.js index 3204b2dbb..27c254e80 100644 --- a/src/display/editor/annotation_editor_layer.js +++ b/src/display/editor/annotation_editor_layer.js @@ -561,6 +561,11 @@ class AnnotationEditorLayer { * @param {Object} parameters */ update(parameters) { + // Editors have their dimensions/positions in percent so to avoid any + // issues (see #15582), we must commit the current one before changing + // the viewport. + this.#uiManager.commitOrRemove(); + this.viewport = parameters.viewport; this.setDimensions(); this.updateMode(); diff --git a/src/display/editor/tools.js b/src/display/editor/tools.js index 542784d1e..dd0629595 100644 --- a/src/display/editor/tools.js +++ b/src/display/editor/tools.js @@ -941,11 +941,7 @@ class AnnotationEditorUIManager { * Delete the current editor or all. */ delete() { - if (this.#activeEditor) { - // An editor is being edited so just commit it. - this.#activeEditor.commitOrRemove(); - } - + this.commitOrRemove(); if (!this.hasSelection) { return; } @@ -965,6 +961,11 @@ class AnnotationEditorUIManager { this.addCommands({ cmd, undo, mustExec: true }); } + commitOrRemove() { + // An editor is being edited so just commit it. + this.#activeEditor?.commitOrRemove(); + } + /** * Select the editors. * @param {Array} editors