Skip to content
Snippets Groups Projects
Commit 600836d7 authored by chris's avatar chris
Browse files

browser history fixed

parent 22eae382
No related branches found
No related tags found
No related merge requests found
......@@ -53,7 +53,7 @@ class ContainerEditor extends SubstanceContainerEditor {
const editor = this.getEditor()
editor.send('changesNotSaved')
editor.emit('send:route', location.pathname)
editor.emit('send:route', {location: location.pathname, back: false})
return callback(false)
}
......@@ -79,9 +79,9 @@ class ContainerEditor extends SubstanceContainerEditor {
window.history.pushState(null, null, document.URL)
editor.send('changesNotSaved')
editor.emit('send:route', url)
editor.emit('send:route', {location: url, back: true})
} else {
this.props.history.push(url)
this.props.history.goBack()
}
}
......
......@@ -7,6 +7,7 @@ class ModalWarning extends Modal {
this.parent.on('send:route', this._getNextRoute, this)
this.route = ''
this.backButton = false
}
render ($$) {
......@@ -52,16 +53,19 @@ class ModalWarning extends Modal {
return el
}
_getNextRoute (route) {
this.route = route
_getNextRoute (args) {
this.route = args.location
this.backButton = args.back
}
_saveExitWriter () {
this.rerender()
this.context.editor.editorSession.save()
// TODO -- ??
setTimeout(() => { this.context.editor.props.history.push(this.route) }, 200)
if (this.backButton) {
setTimeout(() => { this.context.editor.props.history.go(-2) }, 200)
} else {
setTimeout(() => { this.context.editor.props.history.push(this.route) }, 200)
}
}
// TODO: Hack Check why cannot rerender editor so can push to url
......@@ -72,7 +76,12 @@ class ModalWarning extends Modal {
})
this.context.editor.editorSession.save()
setTimeout(() => { this.context.editor.props.history.push(this.route) }, 200)
if (this.backButton) {
setTimeout(() => { this.context.editor.props.history.go(-2) }, 200)
} else {
// TODO: Hack Check why cannot rerender editor so can push to url
setTimeout(() => { this.context.editor.props.history.push(this.route) }, 200)
}
}
}
......
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