From 63c1c787b4a6f7d7c909bcd899806746cec32d10 Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Fri, 22 Mar 2024 20:28:39 +0100 Subject: [PATCH] [Editor] Add a label to the highight floating button readable with NVDA (bug 1886964) --- l10n/en-US/viewer.ftl | 4 +++- src/display/editor/toolbar.js | 6 +++++- web/annotation_editor_layer_builder.css | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/l10n/en-US/viewer.ftl b/l10n/en-US/viewer.ftl index 3804a3bd4d301..8aea43959e0bd 100644 --- a/l10n/en-US/viewer.ftl +++ b/l10n/en-US/viewer.ftl @@ -318,8 +318,10 @@ pdfjs-editor-stamp-button-label = Add or edit images pdfjs-editor-highlight-button = .title = Highlight pdfjs-editor-highlight-button-label = Highlight -pdfjs-highlight-floating-button = +pdfjs-highlight-floating-button1 = .title = Highlight + .aria-label = Highlight +pdfjs-highlight-floating-button-label = Highlight ## Remove button for the various kind of editor. diff --git a/src/display/editor/toolbar.js b/src/display/editor/toolbar.js index 9916b206207d9..ea493004537c1 100644 --- a/src/display/editor/toolbar.js +++ b/src/display/editor/toolbar.js @@ -202,7 +202,11 @@ class HighlightToolbar { const button = document.createElement("button"); button.className = "highlightButton"; button.tabIndex = 0; - button.setAttribute("data-l10n-id", `pdfjs-highlight-floating-button`); + button.setAttribute("data-l10n-id", `pdfjs-highlight-floating-button1`); + const span = document.createElement("span"); + button.append(span); + span.className = "visuallyHidden"; + span.setAttribute("data-l10n-id", "pdfjs-highlight-floating-button-label"); button.addEventListener("contextmenu", noContextMenu); button.addEventListener("click", () => { this.#uiManager.highlightSelection("floating_button"); diff --git a/web/annotation_editor_layer_builder.css b/web/annotation_editor_layer_builder.css index a05357aba7712..6d96de291b38c 100644 --- a/web/annotation_editor_layer_builder.css +++ b/web/annotation_editor_layer_builder.css @@ -52,6 +52,8 @@ * for screen readers. */ .visuallyHidden { position: absolute; + top: 0; + left: 0; border: 0; margin: 0; padding: 0;