Skip to content

[Editor] Add an aria-label to the alt-text button depending on its state #16990

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions l10n/en-US/viewer.properties
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ editor_ink_canvas_aria_label=User-created image
# LOCALIZATION NOTE (editor_alt_text_button_label): Alternative text (alt text) helps
# when people can't see the image.
editor_alt_text_button_label=Alt text
editor_alt_text_edit_button_label=Edit alt text
editor_alt_text_dialog_label=Choose an option
editor_alt_text_dialog_description=Alt text (alternative text) helps when people can’t see the image or when it doesn’t load.
editor_alt_text_add_description_label=Add a description
Expand Down
8 changes: 8 additions & 0 deletions src/display/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class AnnotationEditor {
AnnotationEditor._l10nPromise ||= new Map(
[
"editor_alt_text_button_label",
"editor_alt_text_edit_button_label",
"editor_alt_text_decorative_tooltip",
].map(str => [str, l10n.get(str)])
);
Expand Down Expand Up @@ -831,6 +832,7 @@ class AnnotationEditor {
.get("editor_alt_text_button_label")
.then(msg => {
altText.textContent = msg;
altText.setAttribute("aria-label", msg);
});
altText.tabIndex = "0";
altText.addEventListener(
Expand Down Expand Up @@ -865,6 +867,12 @@ class AnnotationEditor {
if (!button || (!this.#altTextDecorative && !this.#altText)) {
return;
}
AnnotationEditor._l10nPromise
.get("editor_alt_text_edit_button_label")
.then(msg => {
button.setAttribute("aria-label", msg);
});

let tooltip = this.#altTextTooltip;
if (!tooltip) {
this.#altTextTooltip = tooltip = document.createElement("span");
Expand Down
1 change: 1 addition & 0 deletions web/l10n_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const DEFAULT_L10N_STRINGS = {
editor_ink2_aria_label: "Draw Editor",
editor_ink_canvas_aria_label: "User-created image",
editor_alt_text_button_label: "Alt text",
editor_alt_text_edit_button_label: "Edit alt text",
editor_alt_text_decorative_tooltip: "Marked as decorative",
};
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
Expand Down