-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Description
Describe the bug
When an input is the last focusable element of a Dropdown menu, tabbing from this element change the focus to the next focusable element outside the menu, but does not close the menu.
To Reproduce
Steps to reproduce the behavior:
- Create a Dropdown with a toggle and a menu containing a text input, and another input after and oustide the Dropdown.
- Open the menu by clicking the toggle.
- Focus the text input inside the menu.
- Type the 'Tab' key to focus the input outside the Dropdown.
- The menu stays open.
Reproducible Example
Minimal example by using CodeSandbox.
Expected behavior
The menu should close when tabbing out from the menu.
Screenshots
Environment (please complete the following information)
- Operating System: debian
- Chrome, Version 123.0.6312.58
- react-restart/ui Version 1.6.8
Additional context
I believe it can be solved by adding a key !== 'Tab' condition to Dropdown.tsx:279 like so :
if (
isInput &&
(key === ' ' ||
(key !== 'Escape' && key !== 'Tab' && fromMenu) ||
(key === 'Escape' && (target as HTMLInputElement).type === 'search'))
) {
return;
}If the 'Tab' key does not change focus and is instead used as a tabulation inside the text input, the next keyup event would have that input as a target and the menu will not be toggled.
Metadata
Metadata
Assignees
Labels
No labels
