diff --git a/src/common/Popup/Popup.js b/src/common/Popup/Popup.js index e82a9d473..42c32d0aa 100644 --- a/src/common/Popup/Popup.js +++ b/src/common/Popup/Popup.js @@ -26,6 +26,16 @@ class Popup extends PureComponent { window.removeEventListener('keyup', this.onKeyUp); } + componentDidUpdate(prevProps, prevState) { + if (prevState.isOpen !== this.state.isOpen) { + if (this.state.isOpen && typeof this.props.onAfterOpen === 'function') { + this.props.onAfterOpen(); + } else if (!this.state.isOpen && typeof this.props.onAfterClose === 'function') { + this.props.onAfterClose(); + } + } + } + onKeyUp = (event) => { if (event.keyCode === 27) { this.close(event); @@ -129,4 +139,9 @@ Popup.Menu.propTypes = { width: PropTypes.number }; +Popup.propTypes = { + onAfterOpen: PropTypes.func, + onAfterClose: PropTypes.func +}; + export default Popup;