Skip to content

md-menu: Blocked aria-hidden on an element because its descendant retained focus. #5760

@austinw-fineart

Description

@austinw-fineart

What is affected?

Accessibility, Component

Description

When defocusing a menu in a specific way, the following error appears in the console:

Blocked aria-hidden on an element because its descendant retained focus. The focus must not be hidden from assistive technology users. Avoid using aria-hidden on a focused element or its ancestor. Consider using the inert attribute instead, which will also prevent focus. For more details, see the aria-hidden section of the WAI-ARIA specification at https://w3c.github.io/aria/#aria-hidden.
Element with focus: li
Ancestor with aria-hidden: <md-menu id=​"usage-menu" anchor=​"usage-anchor" aria-hidden=​"true">​…​​

This error will only appear when the following conditions are met:

  1. The menu must be fully open (the menu will not auto-close otherwise)
  2. The new focus must be something outside of the current browser page (another tab, window, app, etc.)
  3. The error will only appear once per menu

Reproduction

https://material-web.dev/components/menu/

Workaround

I have not found a workaround

Is this a regression?

No or unsure. This never worked, or I haven't tried before.

Affected versions

2.2.0

Browser/OS/Node environment

Browser: Chrome 131.0.6778.205
OS: Windows 11

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