Skip to content

Commit d30d9b7

Browse files
author
Wes Cossick
committed
Fix initial value overwriting autosaved value
1 parent 36f9760 commit d30d9b7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/js/simplemde.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ function SimpleMDE(options) {
941941
// The codemirror component is only available after rendering
942942
// so, the setter for the initialValue can only run after
943943
// the element has been rendered
944-
if(options.initialValue) {
944+
if(options.initialValue && (!this.options.autosave || this.options.autosave.foundSavedValue !== true)) {
945945
this.value(options.initialValue);
946946
}
947947
}
@@ -1081,8 +1081,10 @@ SimpleMDE.prototype.autosave = function() {
10811081
}
10821082

10831083
if(this.options.autosave.loaded !== true) {
1084-
if(typeof localStorage.getItem("smde_" + this.options.autosave.uniqueId) == "string" && localStorage.getItem("smde_" + this.options.autosave.uniqueId) != "")
1084+
if(typeof localStorage.getItem("smde_" + this.options.autosave.uniqueId) == "string" && localStorage.getItem("smde_" + this.options.autosave.uniqueId) != "") {
10851085
this.codemirror.setValue(localStorage.getItem("smde_" + this.options.autosave.uniqueId));
1086+
this.options.autosave.foundSavedValue = true;
1087+
}
10861088

10871089
this.options.autosave.loaded = true;
10881090
}

0 commit comments

Comments
 (0)