From fa7df015687e98b8a91e1b9807afd965fd058bfd Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Thu, 10 Oct 2024 13:38:08 +0200 Subject: [PATCH] Don't add the grey outline when hovering a selected highlight When playing with a pen, I noticed that sometimes a free highlight has still its gray outline when an other one is drawn: for any reason the pointerleave event isn't triggered. --- src/display/editor/annotation_editor_layer.js | 8 -------- src/display/editor/editor.js | 6 +++++- src/display/editor/highlight.js | 8 ++++++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/display/editor/annotation_editor_layer.js b/src/display/editor/annotation_editor_layer.js index 2021b6bbd..1cce51228 100644 --- a/src/display/editor/annotation_editor_layer.js +++ b/src/display/editor/annotation_editor_layer.js @@ -734,14 +734,6 @@ class AnnotationEditorLayer { this.#uiManager.toggleSelected(editor); } - /** - * Check if the editor is selected. - * @param {AnnotationEditor} editor - */ - isSelected(editor) { - return this.#uiManager.isSelected(editor); - } - /** * Unselect an editor. * @param {AnnotationEditor} editor diff --git a/src/display/editor/editor.js b/src/display/editor/editor.js index a76ba95da..e4d3c2152 100644 --- a/src/display/editor/editor.js +++ b/src/display/editor/editor.js @@ -1109,6 +1109,10 @@ class AnnotationEditor { this.#selectOnPointerEvent(event); } + get isSelected() { + return this._uiManager.isSelected(this); + } + #selectOnPointerEvent(event) { const { isMac } = FeatureTest.platform; if ( @@ -1123,7 +1127,7 @@ class AnnotationEditor { } #setUpDragSession(event) { - const isSelected = this._uiManager.isSelected(this); + const { isSelected } = this; this._uiManager.setUpDragSession(); const ac = new AbortController(); diff --git a/src/display/editor/highlight.js b/src/display/editor/highlight.js index f6f603873..a8ef49a8b 100644 --- a/src/display/editor/highlight.js +++ b/src/display/editor/highlight.js @@ -596,11 +596,15 @@ class HighlightEditor extends AnnotationEditor { } pointerover() { - this.parent.drawLayer.addClass(this.#outlineId, "hovered"); + if (!this.isSelected) { + this.parent.drawLayer.addClass(this.#outlineId, "hovered"); + } } pointerleave() { - this.parent.drawLayer.removeClass(this.#outlineId, "hovered"); + if (!this.isSelected) { + this.parent.drawLayer.removeClass(this.#outlineId, "hovered"); + } } #keydown(event) {