Pressing shift + tab selects highlighted item
vongb opened this issue · comments
downshift
version:9.0.6
node
version:v18.20.1
npm
(oryarn
) version:1.22.19
What you did:
- Open the dropdown
- Make sure there is a highlighted item
- Press Shift + Tab
- Dropdown closes (expected)
- Highlighted item selected (unexpected)
This can be reproduced in the useMultipleSelection with combobox example in downshift-js.com
What happened:
Reproduction repository:
Problem description:
If I understand correctly, the highlighted item should not be selected when Shift + Tab is pressed, it should just navigate to the previous element in the tab index. I think it's selecting it because of this code here. When we shift tab to a previous element, that bit will be false
which will tell the reducer to select an item.
Suggested solution:
I'm thinking we can just rely just on checking if the active element is the document body. (Not sure if I'm missing another use case here)
This can be fixed by not calling setSelectedItems
on InputBlur
Ah but if setSelectedItem
is not called for InputBlur
. Pressing Tab
key does not select the highlighted item which is recommended for comboboxes