-
-
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] Prevent backdrop to stay open #16694
Conversation
Details of bundle changes.Comparing: 4d8206d...ea9d330
|
This should address mui#12831. After following the comments in the above issue, I indeed noticed that `onExited` was not called. However, I've also noticed that `onEntered` was not called either. This is because the transition is not even rendered. To solve this, I have added a flag that tells if the transition was entered. If this is not the case, we can remove the modal from the DOM when open is false.
@ValentinH Thanks for giving this issue a try! If you don't mind, I propose a different solution: |
cdd2697
to
5d41805
Compare
5d41805
to
ea9d330
Compare
Your solution is exactly what I had in mind for the "another solution". It's also good that you added the fix for the Popper and Snackbar, thanks for this! 😊 |
@ValentinH I'm not aware of any downside either of the exited initially true approach :) |
Yes it should be fine: I think it makes sense to only set the exited state when the onExited callback is called, regardless of the open state. |
@ValentinH Thanks men, I remember seeing this issue before the hook migration, the logic was scaring, looks à bit simpler now. I really appreciate that you looked for different possible solutions. |
Indeed, the code looked quite straightforward even for a newcomer like me :) hooks helped a lot I think but also the clean implementation. |
Closes #12831.
After following the comments in the above issue, I indeed noticed that
onExited
was not called. However, I've also noticed thatonEntered
was not called either. This is because the transition is not even rendered.To solve this, I have added a flag that tells if the transition was entered. If this is not the case, we can remove the modal from the DOM when open is false.
Another simpler solution would be to always set the
exited
state totrue
on mount:but I wasn't sure of what all the implications could be.