material-components / material-components/material-web
md-menu: Blocked aria-hidden on an element because its descendant retained focus.
Nobody has claimed this yet.
- Dominant language
- SCSS
- Stars
- 11.3k
- Forks
- 1.1k
- Avg merge
- 20h 28m
- Merged PRs (30d)
- 13
Description
### 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: …
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked md-menu reproduction and reproduce the Chrome console warning by fully opening the menu, moving focus outside the page, and allowing it to close. Trace the menu's focus and aria-hidden behavior, then verify that the warning no longer appears under those conditions without breaking normal menu closing or accessibility behavior.
Written by the indexing model from the issue text.
Assessment
- Domain
- accessibility, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100