-
Notifications
You must be signed in to change notification settings - Fork 808
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
Bug: Modal with closeTimeoutMS
unrecoverable with Suspense
#982
Comments
@h3rmanj This is super weird...why is it triggering the fallback if there is still content been displayed? (the |
It is the lazy component that triggers the suspense. Probably, suspense uses conditional rendering on their side and react-modal doesn't play well with it. |
🤔 it must be failing to remove the instance from the manager. |
Do note you have to reload the sandbox each time you try again, as it resolves and triggers the fallback only once per load. Which In the docs it is noted that suspense will call layout effect cleanups, which might include Do note that this is a low-priority bug, which can be easily solved by localizing suspenses etc. But it was something we met, and used some time to understand why happened. I would think that the component would respect the |
My bad...I thought that the react-modal has a small manager to deal with nested modals and dangling references to modals. In this case, since it doesn't trigger the logic to remove the instance from the manager, You must be getting this log message:
|
Right, so if I remove |
If suspense is been triggered, than it must create a new instance of the react-modal/src/helpers/portalOpenInstances.js Lines 9 to 18 in 8a74268
Unless react is doing some black magic to keep the previously rendered tree, and only append what is in "real suspense". |
If I understand the docs right, if the component has initially mounted, but then shows the fallback later, react will preserve the state of the components until the suspense promise is resolved. |
Summary:
Passing
closeTimeoutMS
to an open Modal makes it unrecoverable if it's part of a render that suspends.Steps to reproduce:
Expected behavior:
Modal should be open.
Link to example of issue:
https://codesandbox.io/s/closetimeoutms-and-suspense-nfmelh?file=/src/App.tsx
Additional notes:
If the
closeTimeoutMS
prop is removed from the codesandbox link, everything works as expected.The text was updated successfully, but these errors were encountered: