From e40e372fed38514f00fc07503e6cf5a67594c520 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 28 Jun 2017 23:02:11 -0700 Subject: [PATCH] Fixed: hasPendingChanges Fixed: Vertical alignment changing between read/edit --- frontend/components/Editor/Editor.js | 2 -- frontend/scenes/Document/Document.js | 19 +++++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/frontend/components/Editor/Editor.js b/frontend/components/Editor/Editor.js index 125b1f43..025e5a03 100644 --- a/frontend/components/Editor/Editor.js +++ b/frontend/components/Editor/Editor.js @@ -111,8 +111,6 @@ type KeyData = { render = () => { return ( - {!this.props.readOnly && - } { await this.props.documents.fetch(props.match.params.id); - if (this.document) this.document.view(); + const document = this.document; + + if (document) { + this.props.ui.setActiveDocument(document); + document.view(); + } if (this.props.match.params.edit) { this.props.ui.enableEditMode(); @@ -71,12 +76,14 @@ type Props = { }; onSave = async (redirect: boolean = false) => { - if (!this.document) return; - await this.document.save(); + const document = this.document; + + if (!document) return; + await document.save(); this.props.ui.disableEditMode(); - if (redirect && this.document) { - this.props.history.push(this.document.url); + if (redirect) { + this.props.history.push(document.url); } }; @@ -90,7 +97,7 @@ type Props = { onChange = text => { if (!this.document) return; - this.document.updateData({ text }); + this.document.updateData({ text, hasPendingChanges: true }); }; onCancel = () => {