-
Notifications
You must be signed in to change notification settings - Fork 32
Description
Description
This is a problem with React-Select
as well but, given the fact that this is mostly a UI issue being wrapped in Chakra-react-select
it might be looked at.
When a CreatableSelect
contains values (see the "Select with creatable options" from https://codesandbox.io/s/chakra-react-select-ts-demo-vz9ut?file=/app.tsx), each element has a "clear" button (and, is the isClearable
is set, a final "clear" button for remove all values).
The wrapping component gets the focus and selected state, which means it is impossible to use the tab key to navigate to every clear button one by one. In essence, the focus is on the "fake" wrapping input field, at the expense of the internal composition.
This is a potential violation of the nested-interactive
rule (WCAG 2.1 (A)), see https://dequeuniversity.com/rules/axe/html/4.3/nested-interactive
A better solution would be to redesign the wrapper, using the approach Chakra
uses for the input with an internal button, see https://chakra-ui.com/docs/components/input/usage#password-input-example
chakra-react-select Version
^4.7.6
Link to Reproduction
https://codesandbox.io/s/chakra-react-select-ts-demo-vz9ut?file=/app.tsx
TypeScript?
- Yes I use TypeScript
Steps to reproduce
- Create a
CreatableSelect
<FormControl p={4}>
<FormLabel>Select with creatable options</FormLabel>
<CreatableSelect
isMulti
name="colors"
options={groupedOptions}
placeholder="Select some colors..."
closeMenuOnSelect={false}
/>
</FormControl>
- Add some of the options into the "input"
- check focus and keyboard navigation between the input, elements and "clear" buttons
Operating System
- macOS
- Windows
- Linux
- iOS/iPadOS
- Android
Additional Information
From https://codesandbox.io/s/chakra-react-select-ts-demo-vz9ut?file=/app.tsx, showing the wrapper with the focus
ChakraUI input showing
- first there main wrapper (input) getting the focus
- then the internal button when tab is used to navigate
It is worth noting that, at the moment, the tab key is mapped to adding the selected option into the input, not to navigate to another UI elements (unless all options have been cleared). #
I accept that there might be no easy way of combining both patterns