From 88f3ed7745d35021be7e13d5cd3cfc81613013a8 Mon Sep 17 00:00:00 2001 From: Calixte Denizet <calixte.denizet@gmail.com> Date: Fri, 22 Sep 2023 23:27:51 +0200 Subject: [PATCH] [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). --- src/display/editor/editor.js | 2 ++ web/alt_text_manager.js | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/display/editor/editor.js b/src/display/editor/editor.js index ecea8664a..4297eddbe 100644 --- a/src/display/editor/editor.js +++ b/src/display/editor/editor.js @@ -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 => { diff --git a/web/alt_text_manager.js b/web/alt_text_manager.js index f08a7badc..48bd2df02 100644 --- a/web/alt_text_manager.js +++ b/web/alt_text_manager.js @@ -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);