diff --git a/src/components/Modal/BaseModal.js b/src/components/Modal/BaseModal.js index a4b7ed90a8fe..d9fccfef3312 100644 --- a/src/components/Modal/BaseModal.js +++ b/src/components/Modal/BaseModal.js @@ -16,11 +16,15 @@ const propTypes = { /** The ref to the modal container */ forwardedRef: PropTypes.func, + + /** Ensure that callback and trap deactivation are in the same loop on the web platform */ + shouldUseOnDismiss: PropTypes.bool, }; const defaultProps = { ...modalDefaultProps, forwardedRef: () => {}, + shouldUseOnDismiss: false, }; class BaseModal extends PureComponent { @@ -109,7 +113,8 @@ class BaseModal extends PureComponent { this.props.onModalShow(); }} propagateSwipe={this.props.propagateSwipe} - onModalHide={this.hideModal} + onDismiss={this.props.shouldUseOnDismiss ? this.hideModal : () => {}} + onModalHide={!this.props.shouldUseOnDismiss ? this.hideModal : () => {}} onSwipeComplete={this.props.onClose} swipeDirection={swipeDirection} isVisible={this.props.isVisible} diff --git a/src/components/Modal/index.web.js b/src/components/Modal/index.web.js index 3cb6f3561b60..24c83001698c 100644 --- a/src/components/Modal/index.web.js +++ b/src/components/Modal/index.web.js @@ -29,6 +29,7 @@ const Modal = (props) => {