Added checks in ModalBase, PopoverBase if page goes back/forward to dismiss
• Added: - checks in ModalBase, PopoverBase if page goes back/forward (popstate) to dismiss the modal, popover
This commit is contained in:
parent
7000902ecb
commit
bec3360b66
|
@ -23,10 +23,10 @@ class ModalBase extends React.PureComponent {
|
|||
}
|
||||
}
|
||||
|
||||
handleOnClose = (e) => {
|
||||
handleOnClose = (e, force) => {
|
||||
const { onOpenModal, composeText, composeId, onClose, intl, type, onCancelReplyCompose } = this.props
|
||||
|
||||
if (!!e && this.dialog !== e.target) return
|
||||
if ((!!e && this.dialog !== e.target) && !force) return
|
||||
|
||||
if (!composeId && composeText && type === 'COMPOSE') {
|
||||
onOpenModal('CONFIRM', {
|
||||
|
@ -42,6 +42,7 @@ class ModalBase extends React.PureComponent {
|
|||
|
||||
componentDidMount() {
|
||||
window.addEventListener('keyup', this.handleKeyUp, false)
|
||||
window.addEventListener('popstate', (e) => this.handleOnClose(e, true), false);
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
|
@ -73,6 +74,7 @@ class ModalBase extends React.PureComponent {
|
|||
|
||||
componentWillUnmount() {
|
||||
window.removeEventListener('keyup', this.handleKeyUp)
|
||||
window.removeEventListener('popstate', this.handleOnClose, false);
|
||||
}
|
||||
|
||||
getSiblings = () => {
|
||||
|
|
|
@ -19,12 +19,14 @@ class PopoverBase extends ImmutablePureComponent {
|
|||
document.addEventListener('click', this.handleDocumentClick, false)
|
||||
document.addEventListener('keydown', this.handleKeyDown, false)
|
||||
document.addEventListener('touchend', this.handleDocumentClick, listenerOptions)
|
||||
window.addEventListener('popstate', this.handleClose, false);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
document.removeEventListener('click', this.handleDocumentClick, false)
|
||||
document.removeEventListener('keydown', this.handleKeyDown, false)
|
||||
document.removeEventListener('touchend', this.handleDocumentClick, listenerOptions)
|
||||
window.removeEventListener('hashchange', this.handleClose);
|
||||
}
|
||||
|
||||
handleDocumentClick = (e) => {
|
||||
|
|
Loading…
Reference in New Issue