From 4d9d4405e67fbcd713584b2cafd7d7c8301bdc26 Mon Sep 17 00:00:00 2001 From: cuizhirong Date: Wed, 15 May 2019 10:34:39 +0800 Subject: [PATCH] Allows closing of parent pop Change-Id: I6f86b569c28d799af17aa7ce730559d191b3297f --- js/components/modal/modal.jsx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/js/components/modal/modal.jsx b/js/components/modal/modal.jsx index d37165c..3a7ed00 100644 --- a/js/components/modal/modal.jsx +++ b/js/components/modal/modal.jsx @@ -20,9 +20,14 @@ class Modal extends React.Component { } onClose() { + const closeParent = this.props.closeParent; if (this.props.parent) { this.hide(true); - this.props.parent.show(true); + if (closeParent) { + this.props.parent.onClose(); + } else { + this.props.parent.show(true); + } } else { this.hide(); } @@ -87,7 +92,7 @@ class Modal extends React.Component { componentDidMount() { document.addEventListener('keyup', this.keyboardListener); - + if (this.props.parent) { this.show(true); } else { @@ -125,8 +130,13 @@ class Modal extends React.Component { if (nextProps.visible === true) { this.show(); } else if (this.props.parent) { + const closeParent = nextProps.closeParent; this.hide(true); - this.props.parent.show(true); + if (closeParent) { + this.props.parent.onClose(); + } else { + this.props.parent.show(true); + } } else { this.hide(); } @@ -161,6 +171,7 @@ class Modal extends React.Component { Modal.propTypes = { parent: PropTypes.instanceOf(Modal), + closeParent: PropTypes.bool, title: PropTypes.string, width: PropTypes.number, visible: PropTypes.bool,