diff --git a/app/components/SimpleEditor/ContainerEditor.js b/app/components/SimpleEditor/ContainerEditor.js index 58f0df11df9e5db7ae7d34a2f347848ab9a8101b..c80b368df9b78b149285fccdb6655d19e9106d93 100644 --- a/app/components/SimpleEditor/ContainerEditor.js +++ b/app/components/SimpleEditor/ContainerEditor.js @@ -45,20 +45,22 @@ class ContainerEditor extends SubstanceContainerEditor { this.addTargetToLinks() } - this.props.history.listenBefore((location, callback) => { - const commandStates = this.getCommandStates() + if (this.props.history) { + this.props.history.listenBefore((location, callback) => { + const commandStates = this.getCommandStates() - if (commandStates['save'].disabled === false) { - const editor = this.getEditor() + if (commandStates['save'].disabled === false) { + const editor = this.getEditor() - editor.send('changesNotSaved') - editor.emit('send:route', location.pathname) + editor.send('changesNotSaved') + editor.emit('send:route', location.pathname) - return callback(false) - } + return callback(false) + } - return callback() - }) + return callback() + }) + } window.history.pushState(null, null, document.URL) window.addEventListener('popstate', this.controlBackButton)