Skip to content

Closing a dialog by Escape key is also being considered as keyboard navigation #183

@saschanaz

Description

@saschanaz

WAI-ARIA suggests returning focus to the previously focused element when closing a modal dialog, with an example:

When a dialog closes, focus returns to the element that invoked the dialog unless either:

Using focus-visible here is tricky as currently the polyfill responds to all keydown events and adds .focus-visible class when the ARIA refocusing happens by tapping Escape key to close a dialog.

Maybe we can exclude Escape key from onKeyDown, what do you think?

function onKeyDown(e) {
if (isValidFocusTarget(document.activeElement)) {
addFocusVisibleClass(document.activeElement);
}
hadKeyboardEvent = true;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions