From bdb8410ad477b035267537163295b6d0f75ede52 Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Wed, 27 Sep 2023 14:21:11 +0200 Subject: [PATCH] [Editor] Disabled the alt-text button when the editor is being resized --- src/display/editor/editor.js | 20 ++++++++++++++++++-- web/annotation_editor_layer_builder.css | 4 ++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/display/editor/editor.js b/src/display/editor/editor.js index ce2138940..75dc833c6 100644 --- a/src/display/editor/editor.js +++ b/src/display/editor/editor.js @@ -622,6 +622,8 @@ class AnnotationEditor { return; } + this.#toggleAltTextButton(false); + const boundResizerPointermove = this.#resizerPointermove.bind(this, name); const savedDraggable = this._isDraggable; this._isDraggable = false; @@ -641,6 +643,7 @@ class AnnotationEditor { window.getComputedStyle(event.target).cursor; const pointerUpCallback = () => { + this.#toggleAltTextButton(true); this._isDraggable = savedDraggable; window.removeEventListener("pointerup", pointerUpCallback); window.removeEventListener("blur", pointerUpCallback); @@ -904,8 +907,10 @@ class AnnotationEditor { }, DELAY_TO_SHOW_TOOLTIP); }); button.addEventListener("mouseleave", () => { - clearTimeout(this.#altTextTooltipTimeout); - this.#altTextTooltipTimeout = null; + if (this.#altTextTooltipTimeout) { + clearTimeout(this.#altTextTooltipTimeout); + this.#altTextTooltipTimeout = null; + } this.#altTextTooltip?.classList.remove("show"); }); } @@ -921,6 +926,17 @@ class AnnotationEditor { } } + #toggleAltTextButton(enabled = false) { + if (!this.#altTextButton) { + return; + } + if (!enabled && this.#altTextTooltipTimeout) { + clearTimeout(this.#altTextTooltipTimeout); + this.#altTextTooltipTimeout = null; + } + this.#altTextButton.disabled = !enabled; + } + getClientDimensions() { return this.div.getBoundingClientRect(); } diff --git a/web/annotation_editor_layer_builder.css b/web/annotation_editor_layer_builder.css index a17183370..32fb1753d 100644 --- a/web/annotation_editor_layer_builder.css +++ b/web/annotation_editor_layer_builder.css @@ -481,6 +481,10 @@ inset-block-end: 8px; inset-inline-start: 8px; + &:disabled { + pointer-events: none; + } + &:dir(ltr) { transform-origin: 0 100%; }