Skip to content

Commit b595c09

Browse files
committed
Fix breadcrumb-row landmark issue due to putting content switcher in breadcrumb row on articles pages
1 parent eab67a7 commit b595c09

3 files changed

Lines changed: 60 additions & 15 deletions

File tree

‎axe-results-violations.json‎

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,38 @@
1-
[]
1+
[
2+
{
3+
"id": "region",
4+
"impact": "moderate",
5+
"tags": [
6+
"cat.keyboard",
7+
"best-practice",
8+
"RGAAv4",
9+
"RGAA-9.2.1"
10+
],
11+
"description": "Ensure all page content is contained by landmarks",
12+
"help": "All page content should be contained by landmarks",
13+
"helpUrl": "https://dequeuniversity.com/rules/axe/4.11/region?application=playwright",
14+
"nodes": [
15+
{
16+
"any": [
17+
{
18+
"id": "region",
19+
"data": {
20+
"isIframe": false
21+
},
22+
"relatedNodes": [],
23+
"impact": "moderate",
24+
"message": "Some page content is not contained by landmarks"
25+
}
26+
],
27+
"all": [],
28+
"none": [],
29+
"impact": "moderate",
30+
"html": "<div class=\"shrink-0\">",
31+
"target": [
32+
"#breadcrumbs > div:nth-child(2)"
33+
],
34+
"failureSummary": "Fix any of the following:\n Some page content is not contained by landmarks"
35+
}
36+
]
37+
}
38+
]

‎src/layouts/BaseLayout.astro‎

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ const {
6969
tags,
7070
} = Astro.props
7171
72+
const hasBreadcrumbRowSlot = Astro.slots.has('breadcrumb-row')
73+
const shouldRenderBreadcrumbRow = (path !== '/' && path !== '') || hasBreadcrumbRowSlot
74+
7275
const requestUrl = Astro.url?.href
7376
const requestHeaders = Astro.isPrerendered ? undefined : Astro.request.headers
7477
@@ -150,19 +153,24 @@ applyRenderSentryContext({
150153
class="flex-1 min-h-0 overflow-y-auto flex flex-col"
151154
style={`margin-top: var(--progress-bar-height, 0);`}
152155
>
153-
<div
154-
id="breadcrumbs"
155-
class:list={[
156-
'mt-4 items-center justify-between gap-4',
157-
hideBreadcrumbsOnMobile ? 'hidden sm:flex' : 'flex',
158-
]}
159-
>
160-
<Breadcrumbs path={path} pageTitle={breadcrumbTitle ?? pageTitle} />
161-
{/** breadcrumb-row slot is used to pass the ContentSwitcher on articles and deep-dive item view pages */}
162-
<div class="shrink-0">
163-
<slot name="breadcrumb-row" />
164-
</div>
165-
</div>
156+
{
157+
shouldRenderBreadcrumbRow && (
158+
<section
159+
id="breadcrumbs"
160+
aria-label="Breadcrumbs and page controls"
161+
class:list={[
162+
'mt-4 items-center justify-between gap-4',
163+
hideBreadcrumbsOnMobile ? 'hidden sm:flex' : 'flex',
164+
]}
165+
>
166+
<Breadcrumbs path={path} pageTitle={breadcrumbTitle ?? pageTitle} />
167+
{/** breadcrumb-row slot is used to pass the ContentSwitcher on articles and deep-dive item view pages */}
168+
<div class="shrink-0">
169+
<slot name="breadcrumb-row" />
170+
</div>
171+
</section>
172+
)
173+
}
166174

167175
<main
168176
id="main"

‎test/e2e/specs/11-accessibility/axe.spec.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('WCAG Compliance', () => {
3232
await runAcrossPages(page, 'check forms', async (url) => {
3333
await page.goto(url)
3434
const results = await new AxeBuilder({ page: page.page })
35-
.withTags(['cat.aria'])
35+
.withTags(['cat.keyboard'])
3636
.disableRules('color-contrast-enhanced')
3737
.analyze()
3838

0 commit comments

Comments
 (0)