-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
🐛 Bug Report
At
react-spectrum/packages/@react-spectrum/actionbar/src/ActionBar.tsx
Lines 71 to 78 in 2731ebc
| let {keyboardProps} = useKeyboard({ | |
| onKeyDown(e) { | |
| if (e.key === 'Escape') { | |
| e.preventDefault(); | |
| onClearSelection(); | |
| } | |
| } | |
| }); |
The Esc key to close the ActionBar always clears selection. So if the Esc key is triggered from within the ActionGroupMenu to close the Menu of action items that don't fix within the ActionBar, the current selection will be lost, rather than maintaining selection and restoring focus the the ActionGroup menu trigger.
Also, unlike closing the ActionBar by clicking the Dismiss button, pressing the Esc key does not restore focus to the TableView, but instead focus is lost to the document.body.
🤔 Expected Behavior
Esc key handler should first check that the current focus is actually within the ActionBar, and not within the Portal containing the ActionGroupMenu, before clearing the selection.
When selection is cleared using the Esc key, focus should be restored to the TableView, this may relate to #2444.
😯 Current Behavior
The Esc key to close the ActionBar always clears selection. So if the Esc key is triggered from within the ActionGroupMenu to close the Menu of action items that don't fix within the ActionBar, the current selection will be lost, rather than maintaining selection and restoring focus the the ActionGroup menu trigger.
💁 Possible Solution
Add a test to make sure the target for the Esc keyboard event is a descendant of the ActionBar before clearing selection.
🌍 Your Environment
| Software | Version(s) |
|---|---|
| react-spectrum | @react-spectrum/actionbar v3.0.0-alpha.3 |
| Browser | All |
| Operating System | All |
🧢 Your Company/Team
Adobe/Accessibility