mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-17 20:22:55 +00:00
open/close event callbacks added to Popup's proptypes
This commit is contained in:
parent
60ba1c9172
commit
a8a2bb3327
1 changed files with 15 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue