-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[modal][material-ui] Cannot move focus outside even withdisableEnforceFocus
#44258
Comments
disableEnforceFocus
You seem to be looking for something like non-modal Dialog. We have a demo of how you can build one here: https://mui.com/material-ui/react-dialog/#non-modal-dialog By definition the Modal blocks the interactions outside of it. You were close into setting up the prop on the
This is expected, what it means that you have still the circular tab index inside the component, but you can click or interact otherwise with the content outside of it (e.g. by having a keyboard shortcut to go outside of it). |
If you don't even want to trap focus, then no need to use the |
Okay, I will do that. Thank you very much for the reference and the time you dedicated. |
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Note @Val020213 How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey. |
Steps to reproduce
Link to live example: https://codesandbox.io/p/sandbox/hungry-brahmagupta-57h2pq
Steps to reproduce:
onClose
prop or another clickable component inside.disableEnforceFocus
prop set totrue
and a button that opens the Snackbar message.Current behavior
Current Behavior: Even after setting the
disableEnforceFocus
prop on the Modal, it is not possible to access components outside the Modal when using the Tab key.Expected behavior
Expected Behavior: According to the Focus trap section in the MUI documentation, the Modal component will move focus back to the body if focus tries to escape it. This is implemented for accessibility purposes but may create usability issues.
However, when using
<Modal disableEnforceFocus />
, it should be possible to close the Snackbar or interact with other components on the page.Context
I'm trying to create an accessible user experience where users can open a Snackbar notification from within a Modal, interact with the Snackbar (e.g., close it with an onClose action), and still be able to tab to other interactive components outside the Modal. Setting disableEnforceFocus on the Modal doesn't seem to allow this as expected, so I'm unable to create the intended experience.
I have a global Snackbar provider for my app, where all toast messages are dispatched. Any toast message that isn't opened within the Modal body becomes unfocusable, which disrupts accessibility. Any guidance on enabling this behavior would be greatly appreciated.
Your environment
npx @mui/envinfo
Search keywords: disableEnforceFocus, ada, accessibility, modal, trapFocus
The text was updated successfully, but these errors were encountered: