Fix clicking on a thumbnail image not navigating to the correct page when using a screen reader (bug 2034568)

Screen readers like NVDA fire synthetic click events on the <img> child of the button rather than on the
thumbnailImageContainer element itself, so the strict classList.contains check silently failed.
This commit is contained in:
Calixte Denizet 2026-04-24 10:10:49 +02:00
parent 25204d359a
commit b669fdfc70
No known key found for this signature in database
GPG Key ID: 0C5442631EE0691F
2 changed files with 27 additions and 6 deletions

View File

@ -210,6 +210,30 @@ describe("PDF Thumbnail View", () => {
})
);
});
it("must navigate when a synthetic click is dispatched on the thumbnail image (bug 2034568)", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await showViewsManager(page);
await waitForThumbnailVisible(page, 3);
// Simulate a screen reader (e.g. NVDA) firing a synthetic click on
// the <img> child rather than the thumbnailImageContainer button.
await page.evaluate(() => {
const img = document.querySelector(
`.thumbnail[page-number="3"] .thumbnailImageContainer img`
);
img.dispatchEvent(new MouseEvent("click", { bubbles: true }));
});
const currentPage = await page.$eval(
"#pageNumber",
el => el.valueAsNumber
);
expect(currentPage).withContext(`In ${browserName}`).toBe(3);
})
);
});
});
describe("The manage dropdown menu", () => {

View File

@ -1539,12 +1539,9 @@ class PDFThumbnailViewer {
}
#goToPage(e) {
const { target } = e;
if (target.classList.contains("thumbnailImageContainer")) {
const pageNumber = parseInt(
target.parentElement.getAttribute("page-number"),
10
);
const container = e.target.closest(".thumbnailImageContainer");
if (container) {
const pageNumber = parseInt(container.getAttribute("page-number"), 10);
this.linkService.goToPage(pageNumber);
stopEvent(e);
}