Browse Source

Merge pull request #1781 from weseek/fix/redundant-confirmation-dialog-appears-issue-1780

change timing conditional branch whether this page is first
Yuki Takei 6 years ago
parent
commit
d0573f22e5
1 changed files with 7 additions and 6 deletions
  1. 7 6
      src/client/js/components/PageEditor.jsx

+ 7 - 6
src/client/js/components/PageEditor.jsx

@@ -89,8 +89,13 @@ class PageEditor extends React.Component {
    * @param {string} value
    */
   onMarkdownChanged(value) {
+    const { pageContainer, editorContainer } = this.props;
     this.setMarkdownStateWithDebounce(value);
-    this.saveDraftWithDebounce();
+    // only when the first time to edit
+    if (!pageContainer.state.revisionId) {
+      this.saveDraftWithDebounce();
+    }
+    editorContainer.enableUnsavedWarning();
   }
 
   /**
@@ -270,11 +275,7 @@ class PageEditor extends React.Component {
 
   saveDraft() {
     const { pageContainer, editorContainer } = this.props;
-    // only when the first time to edit
-    if (!pageContainer.state.revisionId) {
-      editorContainer.saveDraft(pageContainer.state.path, this.state.markdown);
-    }
-    editorContainer.enableUnsavedWarning();
+    editorContainer.saveDraft(pageContainer.state.path, this.state.markdown);
   }
 
   clearDraft() {