Skip to content

Commit f3cb2f6

Browse files
fix(component): fix accessibility issue for post-breadcrumbs component (#6294)
## 📄 Description This PR fixes accessibility issues in the post-breadcrumbs component by: - Wrapping breadcrumb items in proper `<li>` elements for semantic HTML structure - Moving `aria-current="page"` attribute from the breadcrumb item to the parent list item - Updating CSS selectors to target the new DOM structure (`li[aria-current="page"] post-breadcrumb-item`) --- ## 📝 Checklist - ✅ My code follows the style guidelines of this project - 🛠️ I have performed a self-review of my own code - 📄 I have made corresponding changes to the documentation - ⚠️ My changes generate no new warnings or errors - 🧪 I have added tests that prove my fix is effective or that my feature works - ✔️ New and existing unit tests pass locally with my changes
1 parent baf037d commit f3cb2f6

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

.changeset/green-crabs-talk.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@swisspost/design-system-components': patch
3+
---
4+
5+
Fixed accessibility issue in the `<post-breadcrumbs>` component by wrapping breadcrumb items in `<li>` elements.

packages/components/src/components/post-breadcrumbs/post-breadcrumbs.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ post-menu::part(popover-container) {
167167
}
168168
}
169169

170-
post-breadcrumb-item:last-of-type {
170+
li[aria-current="page"] post-breadcrumb-item {
171171
pointer-events: none;
172172
color: tokens.get('breadcrumb-selected-fg');
173173
font-weight: tokens.get('breadcrumb-selected-font-weight');

packages/components/src/components/post-breadcrumbs/post-breadcrumbs.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export class PostBreadcrumbs {
139139

140140
{/* Conditionally render concatenated menu or individual breadcrumb items */}
141141
{this.isConcatenated ? (
142-
<div
142+
<li
143143
role="none"
144144
class="menu-trigger-wrapper"
145145
onKeyDown={e => {
@@ -174,19 +174,23 @@ export class PostBreadcrumbs {
174174
))}
175175
</post-menu>
176176
</div>
177-
</div>
177+
</li>
178178
) : (
179179
visibleItems.map(item => (
180-
<post-breadcrumb-item url={item.url} key={item.url || item.text}>
181-
{item.text}
182-
</post-breadcrumb-item>
180+
<li>
181+
<post-breadcrumb-item url={item.url} key={item.url || item.text}>
182+
{item.text}
183+
</post-breadcrumb-item>
184+
</li>
183185
))
184186
)}
185187

186188
{this.lastItem && (
187-
<post-breadcrumb-item url={this.lastItem.url} aria-current="page" tabindex={-1}>
188-
{this.lastItem.text}
189-
</post-breadcrumb-item>
189+
<li aria-current="page">
190+
<post-breadcrumb-item url={this.lastItem.url} tabindex={-1}>
191+
{this.lastItem.text}
192+
</post-breadcrumb-item>
193+
</li>
190194
)}
191195
</ol>
192196

0 commit comments

Comments
 (0)