Skip to content
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

Don't add attribute 'aria-haspopup' when no popup is rendered for an annotation #18889

Merged
merged 1 commit into from
Oct 12, 2024
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
18 changes: 6 additions & 12 deletions src/display/annotation_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,6 @@ class AnnotationElement {
// use of the z-index.
style.zIndex = this.parent.zIndex++;

if (data.popupRef) {
container.setAttribute("aria-haspopup", "dialog");
}

if (data.alternativeText) {
container.title = data.alternativeText;
}
Expand Down Expand Up @@ -624,8 +620,7 @@ class AnnotationElement {
* @memberof AnnotationElement
*/
_createPopup() {
const { container, data } = this;
container.setAttribute("aria-haspopup", "dialog");
const { data } = this;

const popup = (this.#popupElement = new PopupAnnotationElement({
data: {
Expand Down Expand Up @@ -2091,6 +2086,7 @@ class PopupAnnotationElement extends AnnotationElement {
const elementIds = [];
for (const element of this.elements) {
element.popup = popup;
element.container.ariaHasPopup = "dialog";
elementIds.push(element.data.id);
element.addHighlightArea();
}
Expand Down Expand Up @@ -2853,15 +2849,13 @@ class InkAnnotationElement extends AnnotationElement {
polyline.setAttribute("stroke", "transparent");
polyline.setAttribute("fill", "transparent");

// Create the popup ourselves so that we can bind it to the polyline
// instead of to the entire container (which is the default).
if (!popupRef && this.hasPopupData) {
this._createPopup();
}

svg.append(polyline);
}

if (!popupRef && this.hasPopupData) {
this._createPopup();
}

this.container.append(svg);
this._editOnDoubleClick();

Expand Down
30 changes: 30 additions & 0 deletions test/integration/annotation_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -624,4 +624,34 @@ describe("ResetForm action", () => {
});
});
});

describe("Annotation with empty popup and aria", () => {
describe("issue14438.pdf", () => {
let pages;

beforeAll(async () => {
pages = await loadAndWait(
"highlights.pdf",
"[data-annotation-id='693R']"
);
});

afterAll(async () => {
await closePages(pages);
});

it("must check that the highlight annotation has no popup and no aria-haspopup attribute", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await page.waitForFunction(
// No aria-haspopup attribute,
`document.querySelector("[data-annotation-id='693R']").ariaHasPopup === null` +
// and no popup.
`&& document.querySelector("[data-annotation-id='694R']") === null`
);
})
);
});
});
});
});