diff --git a/app/components/SimpleEditor/ContainerEditor.js b/app/components/SimpleEditor/ContainerEditor.js index c80b368df9b78b149285fccdb6655d19e9106d93..e124656032bf8d768371d3a6be4e4443bcfe84d5 100644 --- a/app/components/SimpleEditor/ContainerEditor.js +++ b/app/components/SimpleEditor/ContainerEditor.js @@ -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() } } diff --git a/app/components/SimpleEditor/elements/modal_warning/ModalWarning.js b/app/components/SimpleEditor/elements/modal_warning/ModalWarning.js index 627b17e247de78e48d6a4a2258da66e3e9c4d0da..8462b7eca083efc5ba2581744d7de25b0bbe37ac 100644 --- a/app/components/SimpleEditor/elements/modal_warning/ModalWarning.js +++ b/app/components/SimpleEditor/elements/modal_warning/ModalWarning.js @@ -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) + } } }