-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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 or Dialog]: Modal Background Overlap When Used in map() Without Unique id #44457
Comments
Please provide a github or sandbox link that shows the problem, the description are very unclear |
Exapmple code with UniqueID (alternative solution):
|
@Bittukr7479 You need to maintain a separate open state for each modal. Currently, the same open state is being used for all modals, causing all of them to open when any button is clicked. I have updated the sandbox to track the open state for each modal individually. |
👋 Thanks for using this project! We use GitHub issues exclusively as a bug and feature requests tracker, however, this issue appears to be a support request. For support with Material UI please check out https://mui.com/material-ui/getting-started/support/. Thanks! If you have a question on Stack Overflow, you are welcome to link to it here, it might help others. |
Steps to reproduce
Current behavior
When using the Modal component inside a map() function without unique state or IDs:
Clicking the "Open Modal" button for any item in the list opens all modals in the map() simultaneously.
The Modal's backdrop (BackdropComponent) becomes darker or fully black, with each modal stacking a new backdrop.
This occurs regardless of whether only one modal is intended to open.
Expected behavior
Context
I am trying to render multiple modals dynamically using a map() function for a list of items. Each modal should work independently. However, the issue arises when:
Your environment
npx @mui/envinfo
Search keywords: Dialog Modal
The text was updated successfully, but these errors were encountered: