Skip to content
Snippets Groups Projects
Commit 2fa54f59 authored by john's avatar john
Browse files

check if there is a history prop on surface before using it

parent 523363fc
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment