Skip to content

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

Closed as not planned

Description

@dkeele

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

Activity

  1. changed the title [-][DropdownMenu] Escape closes all submenus[/-] [+][DropdownMenu] Escape does not comply with ARIA authoring practices[/+] on Feb 9, 2023
  2. added a commit that references this issue on Feb 17, 2023
    2724752
  3. benoitgrelard commented on Mar 16, 2023

    @benoitgrelard
    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

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