fix(a11y)6-7-8: replace menu with list and make cluster chooser focusable#4392
fix(a11y)6-7-8: replace menu with list and make cluster chooser focusable#4392Sagar-6203620715 wants to merge 1 commit intokubernetes-sigs:mainfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Sagar-6203620715 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Signed-off-by: Sagar Choudhary <sagar6203620715@gmail.com>
a5d36dd to
030b7f4
Compare
There was a problem hiding this comment.
Pull request overview
This PR addresses three accessibility violations in the ClusterChooserPopup component identified in issue #4385:
- Fixes ARIA required children violations (point 6) by replacing MenuList/MenuItem with List/ListItemButton
- Fixes list item structure violations (point 7) by ensuring ListSubheader is contained within a proper List parent
- Addresses scrollable region focusability (point 8) by adding tabIndex={0} to the List
Changes:
- Replaced
MenuListwithListandMenuItemwithListItemButtonto use semantic HTML list structure instead of ARIA menu roles - Added
tabIndex={0}to make the scrollable List keyboard focusable - Updated imports to reflect the component changes
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <MenuList | ||
| <List | ||
| id="cluster-chooser-list" | ||
| tabIndex={0} |
There was a problem hiding this comment.
Adding tabIndex={0} to the List makes it focusable, but there's no onKeyDown handler on the List itself - the keyboard navigation handler is on the TextField (line 247). This means:
- Users can tab to the List, but keyboard navigation (Arrow Up/Down, Enter) only works when the TextField is focused
- This creates a confusing UX where tabbing to the List provides no interactive functionality
Consider either:
- Removing
tabIndex={0}from the List since the ListItemButton children are already focusable and keyboard-navigable - Or moving/duplicating the
onKeyDownhandler to the List component to enable keyboard navigation from the List itself
The scrollable region accessibility requirement is likely already satisfied by having focusable children (ListItemButtons) within the scrollable container.
| tabIndex={0} |
| <MenuItem | ||
| <ListItemButton | ||
| selected={selected} | ||
| key={`recent_cluster_${cluster.name}`} |
There was a problem hiding this comment.
The key prop on line 49 is redundant. The key prop is already correctly specified where ClusterListItem is rendered (lines 292 and 303). React does not pass the key prop to child components, so this has no effect. Consider removing it to avoid confusion.
| key={`recent_cluster_${cluster.name}`} |
illume
left a comment
There was a problem hiding this comment.
Thanks for this!
To update the snapshots you can run this.
npm run test -- -u
You can check things locally with these commands.
npm run tsc
npm run lint
npm run test
npm run format
Please check the open comments?
|
PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
hey hey. I'll mark this as draft for now to make it easier on reviewers. If you want to continue it, please mark it as ready to review when you've pushed changes. |
Summary
This PR fixes multiple accessibility issues in
ClusterChooserPopupby correcting ARIA roles, list structure, and focus behavior.Related Issue
Partially fixes #4385
Addresses points 6, 7, and 8 from issue #4385
Changes
MenuList/MenuItemwith semanticList/ListItemButtonListSubheaderis contained within a proper list parenttabIndex={0}role="listbox"Tested by: