From a8a2bb332757b9ed2ecfc03b1b037db677a46510 Mon Sep 17 00:00:00 2001 From: NikolaBorislavovHristov Date: Wed, 20 Jun 2018 17:38:52 +0300 Subject: [PATCH] open/close event callbacks added to Popup's proptypes --- src/common/Popup/Popup.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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;