Repository navigation
fix(telekom-nav-list): expose main navigation links as links, not menu items - #2571
khushi-git-7 wants to merge 2 commits into
Conversation
…u items A nav list with variant="main-nav" defaulted to role="menu", so its items set role="menuitem" on their links. Default the main-nav list to role="list" and its items to role="listitem", and keep the native link role. The other variants keep their menu roles, and a role set by the consumer is still used. Closes telekom#2557
There was a problem hiding this comment.
🟡 Changes recommended
The supported flyout dropdown composition assigns role="none" to navigation items, leaving the enclosing list without listitem descendants and breaking its accessibility semantics.
1 open issue
What changed in this PR
Updates Telekom main navigation to expose a list of native links rather than an application menu, addressing #2557 while preserving menu semantics for other variants and explicit consumer roles.
Changes:
- Computes default list and item roles from the navigation variant and parent role.
- Adds role tests for main navigation, the default variant, function navigation, and explicit overrides.
- Updates prop descriptions and generated documentation.
| File | Description |
|---|---|
packages/components/src/components/telekom/telekom-nav-list/telekom-nav-list.tsx |
Computes and applies the list’s default role. |
packages/components/src/components/telekom/telekom-nav-list/telekom-nav-list.spec.ts |
Adds navigation-role regression tests. |
packages/components/src/components/telekom/telekom-nav-list/readme.md |
Documents variant-dependent role defaults. |
packages/components/src/components/telekom/telekom-nav-item/telekom-nav-item.tsx |
Derives item semantics from the parent role. |
packages/components/src/components/telekom/telekom-nav-item/readme.md |
Documents parent-dependent item role defaults. |
Review effort: Balanced
| const parentRole = this.hostElement.parentElement?.getAttribute('role'); | ||
| return parentRole === 'list' ? 'listitem' : 'none'; |
There was a problem hiding this comment.
Thanks, good catch. Fixed in 52c1f55: when the nav list has role="list", a direct child that isn't a nav item and has no role of its own, like the scale-menu-flyout wrapper, gets role="listitem". The nav item inside the wrapper keeps role="none" and its button keeps its native role. A new spec test covers this composition.

Fixes #2557
@maomaoZH @amir-ba could one of you review this? It follows the approach I proposed on the issue.
scale-telekom-nav-listdefaulted torole="menu", andscale-telekom-nav-itemthen gave its linkrole="menuitem", so the main navigation was announced as an application menu instead of a list of links.scale-telekom-nav-list: with noroleset, avariant="main-nav"list (also the default variant) getsrole="list". The other variants keeprole="menu".scale-telekom-nav-item: with noroleset, an item in arole="list"parent getsrole="listitem", otherwiserole="none"as before. Since the parent isn't a menu, the link keeps its native role.role="list"nav list that isn't a nav item and has norole, such as thescale-menu-flyoutwrapper in the dropdown composition, getsrole="listitem". The nav item inside it then keepsrole="none", so the list still has list items.roleset by the consumer is still used for both. Theroleprops no longer have a default value orreflect, so the computed role can be set on the host. Withreflect, Stencil writes the prop value over the host'sroleattribute.Tests: new
telekom-nav-list.spec.ts:main-navgiveslist/listitemand the link has norolevariantbehaves likemain-navfunctionskeepsmenu/none/menuitemscale-menu-flyoutwrapper becomes thelistitem, the nav item inside it staysnone, and its button has norolerole="menu"set on amain-navlist keeps the menu rolesI ran build-pr on my fork. With the change, every job passes (tslint, prettier, uncommitted changes, unit, e2e and visual tests). With only the source change reverted, the three
main-navtests fail and the rest pass. The e2e test "should skip disabled options when typing" failed once in that run, as it did on #2568; it's timing-sensitive and unrelated.