[Editor] Disabled the alt-text button when the editor is being resized

This commit is contained in:
Calixte Denizet 2023-09-27 14:21:11 +02:00
parent 3f7060e777
commit bdb8410ad4
2 changed files with 22 additions and 2 deletions

View File

@ -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();
}

View File

@ -481,6 +481,10 @@
inset-block-end: 8px;
inset-inline-start: 8px;
&:disabled {
pointer-events: none;
}
&:dir(ltr) {
transform-origin: 0 100%;
}