Skip to content

Commit b7cebb3

Browse files
fix(component): resolve accessibility violations in the post-language-switch component (#4951)
## 📄 Description Resolved accessibility violations in the `post-language-switch` component by adding the role="menu" to the `post-menu` component. ## 📝 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 6fe7cac commit b7cebb3

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed
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+
Resolved accessibility violations in the `post-language-switch` component by adding the role="menu" to the `post-menu` component.

packages/components/src/components/post-language-option/post-language-option.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export class PostLanguageOption {
123123
};
124124

125125
return (
126-
<Host data-version={version} role={this.variant ? `${this.variant}item` : null}>
126+
<Host data-version={version}>
127127
{this.url ? (
128128
<a
129129
aria-current={this.active ? 'page' : undefined}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,16 +197,14 @@ export class PostMenu {
197197
slottedElements
198198
// If the element is a slot, get the assigned elements
199199
.flatMap(el => (el instanceof HTMLSlotElement ? el.assignedElements() : el))
200-
// Filter out elements that have a 'menuitem' role
201-
.filter(el => el.getAttribute('role') === 'menuitem')
202200
// For each menu item, get any focusable children (e.g., buttons, links)
203201
.flatMap(el => Array.from(getFocusableChildren(el)))
204202
);
205203
}
206204

207205
render() {
208206
return (
209-
<Host data-version={version}>
207+
<Host data-version={version} role="menu">
210208
<post-popovercontainer placement={this.placement} ref={e => (this.popoverRef = e)}>
211209
<div class="popover-container" part="popover-container">
212210
<slot></slot>

0 commit comments

Comments
 (0)