Don't add attribute 'aria-haspopup' when no popup is rendered for an annotation
and for ink annotations, create the popup after the loop in order to avoid useless elements creation.
This commit is contained in:
parent
5f522d1c60
commit
7c43cb2dae
@ -285,10 +285,6 @@ class AnnotationElement {
|
|||||||
// use of the z-index.
|
// use of the z-index.
|
||||||
style.zIndex = this.parent.zIndex++;
|
style.zIndex = this.parent.zIndex++;
|
||||||
|
|
||||||
if (data.popupRef) {
|
|
||||||
container.setAttribute("aria-haspopup", "dialog");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.alternativeText) {
|
if (data.alternativeText) {
|
||||||
container.title = data.alternativeText;
|
container.title = data.alternativeText;
|
||||||
}
|
}
|
||||||
@ -624,8 +620,7 @@ class AnnotationElement {
|
|||||||
* @memberof AnnotationElement
|
* @memberof AnnotationElement
|
||||||
*/
|
*/
|
||||||
_createPopup() {
|
_createPopup() {
|
||||||
const { container, data } = this;
|
const { data } = this;
|
||||||
container.setAttribute("aria-haspopup", "dialog");
|
|
||||||
|
|
||||||
const popup = (this.#popupElement = new PopupAnnotationElement({
|
const popup = (this.#popupElement = new PopupAnnotationElement({
|
||||||
data: {
|
data: {
|
||||||
@ -2091,6 +2086,7 @@ class PopupAnnotationElement extends AnnotationElement {
|
|||||||
const elementIds = [];
|
const elementIds = [];
|
||||||
for (const element of this.elements) {
|
for (const element of this.elements) {
|
||||||
element.popup = popup;
|
element.popup = popup;
|
||||||
|
element.container.ariaHasPopup = "dialog";
|
||||||
elementIds.push(element.data.id);
|
elementIds.push(element.data.id);
|
||||||
element.addHighlightArea();
|
element.addHighlightArea();
|
||||||
}
|
}
|
||||||
@ -2853,15 +2849,13 @@ class InkAnnotationElement extends AnnotationElement {
|
|||||||
polyline.setAttribute("stroke", "transparent");
|
polyline.setAttribute("stroke", "transparent");
|
||||||
polyline.setAttribute("fill", "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);
|
svg.append(polyline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!popupRef && this.hasPopupData) {
|
||||||
|
this._createPopup();
|
||||||
|
}
|
||||||
|
|
||||||
this.container.append(svg);
|
this.container.append(svg);
|
||||||
this._editOnDoubleClick();
|
this._editOnDoubleClick();
|
||||||
|
|
||||||
|
|||||||
@ -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`
|
||||||
|
);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user