From 6d0676fd86f966de75f948b78ce22888fd356cdd Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Wed, 20 Jul 2022 13:24:42 +0200 Subject: [PATCH] [Editor] No need to click twice to create an editor when the last one is empty --- src/display/editor/annotation_editor_layer.js | 3 ++- src/display/editor/tools.js | 12 +++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/display/editor/annotation_editor_layer.js b/src/display/editor/annotation_editor_layer.js index 2024f9189..497ac484d 100644 --- a/src/display/editor/annotation_editor_layer.js +++ b/src/display/editor/annotation_editor_layer.js @@ -572,7 +572,8 @@ class AnnotationEditorLayer { return; } - this.#allowClick = !this.#uiManager.hasActive(); + const editor = this.#uiManager.getActive(); + this.#allowClick = !editor || editor.isEmpty(); } /** diff --git a/src/display/editor/tools.js b/src/display/editor/tools.js index 212fae6ff..6e762ce64 100644 --- a/src/display/editor/tools.js +++ b/src/display/editor/tools.js @@ -938,7 +938,9 @@ class AnnotationEditorUIManager { for (const editor of this.#allEditors.values()) { editor.unselect(); } - this.#dispatchUpdateStates({ hasSelectedEditor: this.hasActive() }); + this.#dispatchUpdateStates({ + hasSelectedEditor: this.#activeEditor !== null, + }); } /** @@ -958,14 +960,6 @@ class AnnotationEditorUIManager { return this.#activeEditor; } - /** - * Check if there is an active editor. - * @returns {boolean} - */ - hasActive() { - return this.#activeEditor !== null; - } - /** * Get the current editor mode. * @returns {number}