From 3b09d85da8a97ff47bb3af17bb690f0faed63658 Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Sun, 5 Jun 2016 19:31:08 -0700 Subject: [PATCH] Reset editor when entering new document view --- src/scenes/DocumentEdit/DocumentEdit.js | 1 + src/scenes/DocumentEdit/DocumentEditStore.js | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/scenes/DocumentEdit/DocumentEdit.js b/src/scenes/DocumentEdit/DocumentEdit.js index 91801196c..371e9441f 100644 --- a/src/scenes/DocumentEdit/DocumentEdit.js +++ b/src/scenes/DocumentEdit/DocumentEdit.js @@ -21,6 +21,7 @@ const cx = classNames.bind(styles); class DocumentEdit extends Component { componentDidMount = () => { // This is a bit hacky, should find a better way + store.reset(); if (this.props.route.newDocument) { store.atlasId = this.props.params.id; store.newDocument = true; diff --git a/src/scenes/DocumentEdit/DocumentEditStore.js b/src/scenes/DocumentEdit/DocumentEditStore.js index 6a4bd055c..89b276210 100644 --- a/src/scenes/DocumentEdit/DocumentEditStore.js +++ b/src/scenes/DocumentEdit/DocumentEditStore.js @@ -17,8 +17,8 @@ const parseHeader = (text) => { const documentEditStore = new class DocumentEditStore { @observable documentId = null; @observable atlasId = null; - @observable title = 'Lets start with a title'; - @observable text = '# Lets start with a title\n\nAnd continue from there...'; + @observable title; + @observable text; @observable newDocument; @observable preview; @@ -97,6 +97,11 @@ const documentEditStore = new class DocumentEditStore { this.preview = !this.preview; } + @action reset = () => { + this.title = 'Lets start with a title'; + this.text = '# Lets start with a title\n\nAnd continue from there...'; + } + constructor() { // Rehydrate settings localforage.getItem(DOCUMENT_EDIT_SETTINGS)