Skip to content

Commit 61de564

Browse files
authored
Merge pull request #20678 from calixteman/bug2016136
Add an aria-label to the checkboxes in the thumbnails view (bug 2016136)
2 parents 3a32ca7 + 65f1b9b commit 61de564

3 files changed

Lines changed: 46 additions & 0 deletions

File tree

l10n/en-US/viewer.ftl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@ pdfjs-thumb-page-title =
200200
pdfjs-thumb-page-canvas =
201201
.aria-label = Thumbnail of Page { $page }
202202
203+
# Variables:
204+
# $page (Number) - the page number
205+
pdfjs-thumb-page-checkbox =
206+
.aria-label = Select page { $page }
207+
203208
## Find panel button title and messages
204209

205210
pdfjs-find-input =

test/integration/thumbnail_view_spec.mjs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import {
22
awaitPromise,
33
closePages,
4+
FSI,
45
kbFocusNext,
56
loadAndWait,
7+
PDI,
68
} from "./test_utils.mjs";
79

810
function waitForThumbnailVisible(page, pageNum) {
@@ -317,4 +319,40 @@ describe("PDF Thumbnail View", () => {
317319
);
318320
});
319321
});
322+
323+
describe("Checkbox accessibility", () => {
324+
let pages;
325+
326+
beforeEach(async () => {
327+
pages = await loadAndWait(
328+
"tracemonkey.pdf",
329+
"#viewsManagerToggleButton",
330+
null,
331+
null,
332+
{ enableSplitMerge: true }
333+
);
334+
});
335+
336+
afterEach(async () => {
337+
await closePages(pages);
338+
});
339+
340+
it("should have accessible label on checkbox", async () => {
341+
await Promise.all(
342+
pages.map(async ([browserName, page]) => {
343+
await page.click("#viewsManagerToggleButton");
344+
345+
await waitForThumbnailVisible(page, 1);
346+
347+
const ariaLabel = await page.$eval(
348+
`.thumbnail[page-number="1"] input[type="checkbox"]`,
349+
el => el.getAttribute("aria-label")
350+
);
351+
expect(ariaLabel)
352+
.withContext(`In ${browserName}`)
353+
.toBe(`Select page ${FSI}1${PDI}`);
354+
})
355+
);
356+
});
357+
});
320358
});

web/pdf_thumbnail_view.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ class PDFThumbnailView extends RenderableView {
125125
const checkbox = (this.checkbox = document.createElement("input"));
126126
checkbox.type = "checkbox";
127127
checkbox.tabIndex = -1;
128+
checkbox.setAttribute("data-l10n-id", "pdfjs-thumb-page-checkbox");
129+
checkbox.setAttribute("data-l10n-args", this.#pageL10nArgs);
128130
imageContainer.append(checkbox);
129131
}
130132

@@ -464,6 +466,7 @@ class PDFThumbnailView extends RenderableView {
464466
setPageLabel(label) {
465467
this.pageLabel = typeof label === "string" ? label : null;
466468
this.image.setAttribute("data-l10n-args", this.#pageL10nArgs);
469+
this.checkbox?.setAttribute("data-l10n-args", this.#pageL10nArgs);
467470
}
468471
}
469472

0 commit comments

Comments
 (0)