[Editor] Disable context menu on alt-text button and in the associated dialog

but keep it for the text area.
Disable pointerdown on the alt-text button to disable dragging the editor
when the button is clicked (especially when slightly moving the mouse
between the down and the up).
This commit is contained in:
Calixte Denizet 2023-09-22 23:27:51 +02:00
parent 85568bd6cc
commit 88f3ed7745
2 changed files with 7 additions and 0 deletions

View File

@ -834,6 +834,8 @@ class AnnotationEditor {
altText.textContent = msg;
altText.setAttribute("aria-label", msg);
altText.tabIndex = "0";
altText.addEventListener("contextmenu", AnnotationEditor.#noContextMenu);
altText.addEventListener("pointerdown", event => event.stopPropagation());
altText.addEventListener(
"click",
event => {

View File

@ -78,6 +78,11 @@ class AltTextManager {
this.#container = container;
dialog.addEventListener("close", this.#close.bind(this));
dialog.addEventListener("contextmenu", event => {
if (event.target !== this.#textarea) {
event.preventDefault();
}
});
cancelButton.addEventListener("click", this.#finish.bind(this));
saveButton.addEventListener("click", this.#save.bind(this));
optionDescription.addEventListener("change", this.#boundUpdateUIState);