Skip to content
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

[Dialog] v5 component renders even if open is false (different from v4) #35991

Open
2 tasks done
sahanaravi opened this issue Jan 29, 2023 · 3 comments
Open
2 tasks done
Assignees
Labels
component: dialog This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation v5.x

Comments

@sahanaravi
Copy link

sahanaravi commented Jan 29, 2023

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 🕹

Link to live example:

Steps:
MUI5 - https://codesandbox.io/s/angry-mclaren-vgmhu6?file=/demo.tsx
1.Embed a Dialog in the code
2.Set it to open={false}
3.The dialog still renders in the DOM but is closed

MUI4- https://codesandbox.io/s/material-demo-forked-qm3dub?file=/demo.js
1.Embed a Dialog in the code
2.Set it to open={false}
3.The dialog does not render in the DOM

This has not been mentioned in the changes in the MUI5 document. This is breaking a few things in my app

Current behavior 😯

1.Embed a Dialog in the code
2.Set it to open={false}
3.The dialog still renders but is closed

Expected behavior 🤔

1.Embed a Dialog in the code
2.Set it to open={false}
3.The dialog should not render

Context 🔦

ON upgrading from MUI4 to MUI5, the dialog behaviour changed causing issues

Your environment 🌎

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.
@sahanaravi sahanaravi added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jan 29, 2023
@hbjORbj hbjORbj changed the title MUI5 Dialog renders even if open is false, which is different from MUI4 behaviour [Dialog] v5 component renders even if open is false (different from v4) Jan 30, 2023
@hbjORbj hbjORbj added component: dialog This is the name of the generic UI component, not the React module! v5.x labels Jan 30, 2023
@mj12albert mj12albert added docs Improvements or additions to the documentation and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Feb 3, 2023
@mj12albert
Copy link
Member

mj12albert commented Feb 3, 2023

@sahanaravi Thanks for reporting this, I think we could document this more clearly

Would you mind sharing more on how this change affects your app ?

@sahanaravi
Copy link
Author

I have a dialog that is on a page and when I close it and then navigate to another page and use browser back button to come back to the page having the dialog, the page freezes and I realized it is because of this issue. It worked fine before migration. I added conditions around the modal and that fixed the problem, but that conditional rendering was not needed in V4

@mj12albert mj12albert assigned mj12albert and unassigned hbjORbj Feb 7, 2023
@gkielwasser
Copy link

gkielwasser commented Mar 5, 2023

I have an issue which seems quite similar (if not the same). It affects my app since I have migrated my app to react 18. Also I use mui v5.

I can only reproduce it from a mobile, not from desktop. Also I cannot reproduce it in a deterministic way. I could reproduce it on Android and iOS on Chrome browser. I have multiple dialogs in my app, all are not affected by this issue. So far I have no clue on how to give a sanbbox to reproduce this issue.

Issue: the dialog keeps rendering randomly even if the open props is falsy. The app with such a bug will becomes unresponsive because the dialog will still be rendered with a 0 opacity container that is covering the whole app.

Waiting for the reason and a solution, I have also put a condition to avoid rendering the dialog while it shouldn't. This hack will of course breaks the modal animation, specially the close one.

 {show && <Dialog open={show}></Dialog>}

Similar: #33748 #32286

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: dialog This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation v5.x
Projects
None yet
Development

No branches or pull requests

4 participants