Skip to content
This repository has been archived by the owner on Mar 1, 2020. It is now read-only.

Commit

Permalink
Allows closing of parent pop
Browse files Browse the repository at this point in the history
Change-Id: I6f86b569c28d799af17aa7ce730559d191b3297f
  • Loading branch information
cuizhirong committed May 24, 2019
1 parent d9bba9f commit 4d9d440
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions js/components/modal/modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -87,7 +92,7 @@ class Modal extends React.Component {

componentDidMount() {
document.addEventListener('keyup', this.keyboardListener);

if (this.props.parent) {
this.show(true);
} else {
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 4d9d440

Please sign in to comment.