Skip to content

Commit c90ea23

Browse files
committed
[Editor] Add an aria-label to the alt-text button depending on its state
1 parent f2d75d9 commit c90ea23

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

l10n/en-US/viewer.properties

+1
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ editor_ink_canvas_aria_label=User-created image
268268
# LOCALIZATION NOTE (editor_alt_text_button_label): Alternative text (alt text) helps
269269
# when people can't see the image.
270270
editor_alt_text_button_label=Alt text
271+
editor_alt_text_edit_button_label=Edit alt text
271272
editor_alt_text_dialog_label=Choose an option
272273
editor_alt_text_dialog_description=Alt text (alternative text) helps when people can’t see the image or when it doesn’t load.
273274
editor_alt_text_add_description_label=Add a description

src/display/editor/editor.js

+8
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ class AnnotationEditor {
150150
AnnotationEditor._l10nPromise ||= new Map(
151151
[
152152
"editor_alt_text_button_label",
153+
"editor_alt_text_edit_button_label",
153154
"editor_alt_text_decorative_tooltip",
154155
].map(str => [str, l10n.get(str)])
155156
);
@@ -831,6 +832,7 @@ class AnnotationEditor {
831832
.get("editor_alt_text_button_label")
832833
.then(msg => {
833834
altText.textContent = msg;
835+
altText.setAttribute("aria-label", msg);
834836
});
835837
altText.tabIndex = "0";
836838
altText.addEventListener(
@@ -865,6 +867,12 @@ class AnnotationEditor {
865867
if (!button || (!this.#altTextDecorative && !this.#altText)) {
866868
return;
867869
}
870+
AnnotationEditor._l10nPromise
871+
.get("editor_alt_text_edit_button_label")
872+
.then(msg => {
873+
button.setAttribute("aria-label", msg);
874+
});
875+
868876
let tooltip = this.#altTextTooltip;
869877
if (!tooltip) {
870878
this.#altTextTooltip = tooltip = document.createElement("span");

web/l10n_utils.js

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ const DEFAULT_L10N_STRINGS = {
8383
editor_ink2_aria_label: "Draw Editor",
8484
editor_ink_canvas_aria_label: "User-created image",
8585
editor_alt_text_button_label: "Alt text",
86+
editor_alt_text_edit_button_label: "Edit alt text",
8687
editor_alt_text_decorative_tooltip: "Marked as decorative",
8788
};
8889
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {

0 commit comments

Comments
 (0)