diff --git a/src/ui/components/Sheet.js b/src/ui/components/Sheet.js index 331a15e35..7858aae17 100644 --- a/src/ui/components/Sheet.js +++ b/src/ui/components/Sheet.js @@ -8,7 +8,10 @@ import {Component} from 'react'; import {createPortal} from 'react-dom'; import {connect} from 'react-redux'; -import {setActiveSheet} from '../../reducers/application.js'; +import { + ACTIVE_SHEET_PLUGIN_SHEET, + setActiveSheet, +} from '../../reducers/application.js'; import type {ActiveSheet} from '../../reducers/application'; @@ -21,6 +24,10 @@ type Props = { * the sheet. */ children: (onHide: () => void) => ?React.Node, + /** + * Function that is called when the sheet becomes hidden. + */ + onHideSheet: () => void, setActiveSheet: (sheet: ActiveSheet) => any, activeSheet: ActiveSheet, }; @@ -58,8 +65,20 @@ class Sheet extends Component { if (prevState.content !== this.state.content) { this.showSheetIfContentsAvailable(); } + if ( + prevProps.activeSheet === ACTIVE_SHEET_PLUGIN_SHEET && + this.props.activeSheet !== ACTIVE_SHEET_PLUGIN_SHEET + ) { + this.onHideSheet(); + } } + onHideSheet = () => { + if (this.props.onHideSheet != null) { + this.props.onHideSheet(); + } + }; + showSheetIfContentsAvailable = () => { if (this.state.content) { this.props.setActiveSheet('PLUGIN_SHEET');