-
Notifications
You must be signed in to change notification settings - Fork 3.9k
close modal when opening new page using keyboard shortcut #15413
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -30,17 +30,28 @@ class BaseModal extends PureComponent { | |||||||||||||||||||
| this.hideModal = this.hideModal.bind(this); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| componentDidMount() { | ||||||||||||||||||||
| if (!this.props.isVisible) { return; } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // To handle closing any modal already visible when this modal is mounted, i.e. PopoverReportActionContextMenu | ||||||||||||||||||||
| Modal.setCloseModal(this.props.onClose); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| componentDidUpdate(prevProps) { | ||||||||||||||||||||
| if (prevProps.isVisible === this.props.isVisible) { | ||||||||||||||||||||
| return; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Modal.willAlertModalBecomeVisible(this.props.isVisible); | ||||||||||||||||||||
| Modal.setCloseModal(this.props.isVisible ? this.props.onClose : null); | ||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @situchan Do you recall why this call is done in that way? i.e. why we need to set the callback to null if this modal is not visible? Why we don't do it the same as if (this.props.isVisible) {
Modal.setModalClose(this.props.onClose);
}
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We pass Lines 17 to 25 in e48121c
Btw, does that cause any issue?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We may have other modals that did set the callback. If we render a new modal invisible, the old visible modal close callback will be overwritten.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Not exactly, but the functional rewrite of the modal seems to be the cause of the regression. I think there was a misunderstanding of how the code is supposed to be executed. Here at this point, |
||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| componentWillUnmount() { | ||||||||||||||||||||
| // we don't want to call the onModalHide on unmount | ||||||||||||||||||||
| this.hideModal(this.props.isVisible); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // To prevent closing any modal already unmounted when this modal still remains as visible state | ||||||||||||||||||||
| Modal.setCloseModal(null); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| /** | ||||||||||||||||||||
|
|
||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.