Skip to content

Commit 3f110a3

Browse files
committed
fix: page header - prefer redundant image link over aria-hidden
1 parent 1714b39 commit 3f110a3

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

blocks/page-header/page-header.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,16 @@ export default async function decorate(block) {
105105
if (pageHeaderData.anchorNode) {
106106
const wrappingAnchor = document.createElement("a");
107107
wrappingAnchor.setAttribute("href", anchorHref);
108-
// Remove from tab order and hide it from assistive tech; avoid repeating the title for screen readers.
109-
wrappingAnchor.setAttribute("tabindex","-1");
110-
wrappingAnchor.setAttribute("aria-hidden","true");
108+
109+
// Give the link a proper accessible name.
110+
wrappingAnchor.setAttribute("aria-label", pageHeaderData.altText ? pageHeaderData.altText : pageHeaderData.title);
111+
112+
// Treat image as decorative. It is already described by the adjacent text.
113+
const imgElement = pageHeaderVisual.querySelector('img');
114+
if (imgElement) {
115+
imgElement.setAttribute("alt","");
116+
}
117+
111118
wrappingAnchor.append(pageHeaderVisual);
112119
pageHeaderVisual = wrappingAnchor;
113120
}

0 commit comments

Comments
 (0)