[Modal] aria-hidden should not be applied on non-portal modals

Open
#19,450 28 comments 35 reactions 1 assignee View on GitHub

@ZeeshanTamboli is already working on this.

Since Aug 25, 2026.

Assessment

This issue has not been assessed yet.

Description

accessibility scope: modal type: bug

aria-hidden=true gets applied on top level container when a modal is opened. But if disablePortal is used, aria-hidden should not be set on that top level container as the modal will be created inline and most likely within that top level container

Running axe on the opened modal yields the following error:

"ARIA hidden element must not contain focusable elements (aria-hidden-focus)"

Fix all of the following:
Focusable content should have tabindex='-1' or be removed from the DOM

You can find more information on this issue here:
https://dequeuniversity.com/rules/axe/3.3/aria-hidden-focus?application=axeAPI

https://www.w3.org/TR/wai-aria-practices/examples/dialog-modal/dialog.html

The dialog element is not a descendant of any element that has aria-hidden set to true.

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

  1. Modal with disablePortal prop is opened and aria-hidden is set to true on top level html node

Expected Behavior 🤔

  1. Modal with disablePortal prop is opened and aria-hidden is not set to true on top level html node
  2. Modal without disablePortal prop is opened and aria-hidden is set to true on top level html node

Steps to Reproduce 🕹

https://codesandbox.io/s/material-mui-demo-9oddt?fontsize=14&hidenavigation=1&theme=dark

Context 🔦

Your Environment 🌎

Tech Version
Material-UI v4.9.0
React v16.12.0
Browser
TypeScript v3.8.0-dev.20200125
etc.
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mui/material-ui

All issues in mui/material-ui

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.