Skip to content

ActionBar: Esc key to close ActionGroupMenu within ActionBar clears selection and closes ActionBar #2449

@majornista

Description

@majornista

🐛 Bug Report

At

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions