From 98b8aa9f503fa9fc0e7c899fe0ca814427e2a8d7 Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Mon, 17 Apr 2017 02:00:22 +0300 Subject: [PATCH] fix for unsaved changes --- app/components/SimpleEditor/ContainerEditor.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/components/SimpleEditor/ContainerEditor.js b/app/components/SimpleEditor/ContainerEditor.js index 2a65916..65ef7f4 100644 --- a/app/components/SimpleEditor/ContainerEditor.js +++ b/app/components/SimpleEditor/ContainerEditor.js @@ -48,9 +48,7 @@ class ContainerEditor extends SubstanceContainerEditor { // TODO -- this.props.history is deprecated and gives a warning if (this.props.history) { this.props.history.listenBefore((location, callback) => { - const commandStates = this.getCommandStates() - - if (this.editorSession.hasUnsavedChanges()) { + if (this.props.containerId === 'body' && this.editorSession.hasUnsavedChanges()) { const editor = this.getEditor() editor.send('changesNotSaved') @@ -69,14 +67,11 @@ class ContainerEditor extends SubstanceContainerEditor { // TODO -- review // messes up browser history controlBackButton () { - const commandStates = this.getCommandStates() - if (!commandStates['save']) return - const url = '/books/' + this.props.book.id + '/book-builder' window.removeEventListener('popstate', this.controlBackButton) - if (this.editorSession.hasUnsavedChanges()) { + if (this.props.containerId === 'body' && this.editorSession.hasUnsavedChanges()) { const editor = this.getEditor() window.history.pushState(null, null, document.URL) -- GitLab