-
Notifications
You must be signed in to change notification settings - Fork 811
[fixed] respect closeTimeoutMS during unmount #253
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
Conversation
|
|
||
| shouldBeClosed: function() { | ||
| return !this.props.isOpen && !this.state.beforeClose; | ||
| return !this.state.isOpen && !this.state.beforeClose; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the Modal is unmounting, it won't have a chance to update the isOpen prop to false; however, the internal setState call will update state.isOpen correctly.
|
@mgh This looks good from a code perspective, but it'd be great to have a spec in place. I think we could do an async spec that verified that the time the callback is called is within some small margin of error from the timeout value specified. |
a7bca07 to
a3e079c
Compare
|
@claydiffrient sounds good. I've updated the test specs to include an async spec as you proposed. The new test queries the DOM after the modal is unmounted to ensure the portal still exists until the |
|
@mgh awesome! Is this action cancelable? (Just a question). |
|
@diasbruno depends on what you mean by cancelable =) the original behavior of closing and then immediately reopening a modal should be unaffected (the first close is canceled and the portal is preserved). Unmounting then remounting the same Modal will not preserve the same portal though, as React instantiates a new Modal instance for each mount and each instance has its own portal. That behavior, though, is the same before and after this commit. |
diasbruno
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebase. 👍
diasbruno
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought If I approve this I could rebase from the interface. :)
|
@diasbruno I rebased. Two things to note:
|
Fixes issue reactjs#17: "When the modal is unmounted, it will abruptly close, not waiting for any animations to finish." The bug was caused by the Modal component unmounting the portal immediately in `componentWillUnmount` regardless of whether the portal is currently closing or would animate to close. Now when a Modal has a non-zero `closeTimeoutMS`, the Modal inspects the portal state before closing. If the portal is open or closing, but not closed, it waits to unmount the portal. If the portal is open and not already closing, the Modal calls closeWithTimeout() to trigger the close. Adds test to ensure portal DOM persists after Modal is unmounted when the Modal has a `closeTimeoutMS` set. Updates existing tests to properly unmount test Modal instances.
|
Yeah, I've added this wrapper on Really like the |
|
Tested and working. |
Fixes #17.
Changes proposed:
closeTimeoutMSis setUpgrade Path (for changed or removed APIs):
Modal), though due to the lack of activity on the referenced issue, I'm guessing most users won't be affected?Acceptance Checklist:
CONTRIBUTING.md.