diff --git a/platform/viewer/src/connectedComponents/ToolbarRow.js b/platform/viewer/src/connectedComponents/ToolbarRow.js index bb488e2f2..a1729a4fc 100644 --- a/platform/viewer/src/connectedComponents/ToolbarRow.js +++ b/platform/viewer/src/connectedComponents/ToolbarRow.js @@ -136,12 +136,32 @@ class ToolbarRow extends Component { } if (activeContextsChanged) { - this.setState({ - toolbarButtons: _getVisibleToolbarButtons.call(this), - }); + this.setState( + { + toolbarButtons: _getVisibleToolbarButtons.call(this), + }, + this.closeCineDialogIfNotApplicable + ); } } + closeCineDialogIfNotApplicable = () => { + const { dialog } = this.props; + let { dialogId, activeButtons, toolbarButtons } = this.state; + if (dialogId) { + const cineButtonPresent = toolbarButtons.find( + button => button.options && button.options.behavior === 'CINE' + ); + if (!cineButtonPresent) { + dialog.dismiss({ id: dialogId }); + activeButtons = activeButtons.filter( + button => button.options && button.options.behavior !== 'CINE' + ); + this.setState({ dialogId: null, activeButtons }); + } + } + }; + render() { const buttonComponents = _getButtonComponents.call( this,