fix(navigation): make vertical navigation more accessible #2181
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR suggests some small but breaking changes to the markup so we can have an accessible vertical navigation component.
Before:
After:
Motivation
This PR was created because the current beta Navigation Svelte component, when in vertical mode, has some accessibility issues around its usage of
role="separator":<li>items themselves which causes screen readers to incorrectly count how many navigation items are present.presentationrole which isn't something we necessarily want in our navigation component.Rationale
This question does a good breakdown of why I went with breaking the different navigation groups into actual separate
<ul>elements. This does mean I had to make some assumptions around nested<ul>elements in the.lesscode but I'm hoping this is an acceptable trade-off to have an accessible component.Additionally, I used an
<h4>(configurable in svelte) element as the group title as that is the recommended approach for screen readers.How to Test
Stacks Docs
The
Titlesvariant is what has changed.<ul>elements for the different navigation groups and each list contains the various navigation items now.Stacks Svelte
NavigationTitlehas been renamed toNavigationGroupand now encapsulates its childNavigationItems.