Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DropdownMenu] Escape does not comply with ARIA authoring practices #1933

Closed
dkeele opened this issue Feb 6, 2023 · 1 comment
Closed

[DropdownMenu] Escape does not comply with ARIA authoring practices #1933

dkeele opened this issue Feb 6, 2023 · 1 comment

Comments

@dkeele
Copy link

dkeele commented Feb 6, 2023

Bug report

Current Behavior

When focusing a menu item within a submenu, escape key closes all menus and submenus.

Expected behavior

When focusing a menu item within a submenu, escape key closes only the containing submenu.

Reproducible example

Radix Docs

Additional context

According to ARIA authoring practices:

Escape: Close the menu that contains focus and return focus to the element or context, e.g., menu button or parent menuitem, from which the menu was opened.

Also, here's an example demonstrating correct behavior

Your environment

Software Name(s) Version
Radix Package(s) @radix-ui/react-dropdown-menu Latest, see docs example.
Browser Edge, Safari, Firefox, Chrome
Operating System osx Ventura 13.1
@dkeele dkeele changed the title [DropdownMenu] Escape closes all submenus [DropdownMenu] Escape does not comply with ARIA authoring practices Feb 9, 2023
cpmsmith added a commit to cpmsmith/radix-ui-primitives that referenced this issue Feb 17, 2023
In accordance with the WAI-ARIA Menu pattern[0]:

    Escape: Close the menu that contains focus and return focus to the
    element or context, e.g., menu button or parent menuitem, from which
    the menu was opened.

[0]: https://www.w3.org/WAI/ARIA/apg/patterns/menubar/

Fixes radix-ui#1933
@benoitgrelard
Copy link
Contributor

Hey @dkeele,

In many ways the aria practices aren't pure specs and also leave stuff to interpretation.
This is one of those cases I think.

Escape: Close the menu that contains focus and return focus to the element or context, e.g., menu button or parent menuitem, from which the menu was opened.

One could interpret this both ways, ie. return to the top-level button OR the parent menuitem. It's not explicitly stated that it should be always menuitem for a submenu.

On top of this, as you point out in your PR #1964, MacOS doesn't behave like that.

Ultimately we took this approach for a few reasons:

  • submenus already have a key to wind down only the submenu (left arrow in LTR)
  • escape key behavior is predictable this way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants