select icon indicating copy to clipboard operation
select copied to clipboard

clear icon keyboard accessibility

Open TkDodo opened this issue 4 years ago • 1 comments

The clearIcon can be any React.ReactNode, so I tried to make it a <button> with an icon to make it keyboard accessible. This generally works fine - navigating with TAB puts the focus on that icon. However, trying to press that button then either via ENTER the SPACE key does not trigger a clear event.

The tests seems to use mousedown:

https://github.com/react-component/select/blob/05d19a953315f4ecd5510dbc6d4bd5230ccff6e5/tests/shared/allowClearTest.tsx#L40-L43

Is there a way to make clearing the value keyboard accessible?

TkDodo avatar Feb 25 '21 10:02 TkDodo

This is a serious accessibility issue. Currently for a single select there is no way for a keyboard user to clear the selection (reopening the dropdown and trying to unselect the selected option will not work either). The component needs to support keyboard focus on the clear icon, or support onKeyDown if the user supplied allowClear icon has a keydown event

dvberzon avatar Jun 16 '25 11:06 dvberzon