[Select] Keyboard navigation does not work if the first child is a ListSubheader
#26790
Closed
2 tasks done
Labels
accessibility
a11y
bug 🐛
Something doesn't work
component: select
This is the name of the generic UI component, not the React module!
Current Behavior 😯
Following the example here I tried to add grouping to my select component. When trying to navigate the example in the documentation with your keyboard it works as expected, similar to how the navigation works without grouping, where I
tab
to give the select focus, and then use thearrow
keys to navigate between the different options with the group headings being skipped.However, in my use case, the group
ListSubheader
is the first child of theSelect
, rather than a selectable option. In this case when Itab
to focus the select and then try to navigate with thearrow
key I am not able to navigate to the options. It is worth noting though that if Itab
again, the group heading receives focus and then I can use the arrow keys to navigate the options. However, the group heading should not be focusable as it's not a selectable option.Expected Behavior 🤔
I should be able to have a group
ListSubheader
as the first child of theSelect
, and still be able to give the componenttab
focus and navigate the selectable options using thearrow
keysSteps to Reproduce 🕹
Codesandbox example
The example contains two
Select
components. One similar to the documentation example which works as expected, and one where the group heading is the first child, which does not work as expectedSteps:
Working
select exampledown arrow
key and the menu opensdown arrow
keyNot Working
select example.down arrow
key and the menu opensdown arrow
key but you can't navigate to the items.tab
and the group heading will be given focus.Context 🔦
I am trying to use the
Select
to provide a grouped list of options that is also keyboard accessible, where the child elements of the select areListsubheader
andMenuItem
.Your Environment 🌎
`npx @material-ui/envinfo`
The text was updated successfully, but these errors were encountered: