-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
When autosave delay is low (few seconds - but it depends on server speed), autosave can kick in after submit event listener was processed and value was removed from local storage. So, the item will be inserted to local storage again. Clearing the timeout in listener fixes this issue for me:
SimpleMDE.prototype.autosave = function() {
//...
if(this.options.autosave.binded !== true) {
if(simplemde.element.form != null && simplemde.element.form != undefined) {
simplemde.element.form.addEventListener("submit", function() {
clearTimeout(simplemde.autosaveTimeoutId);
simplemde.autosaveTimeoutId = undefined;
localStorage.removeItem("smde_" + simplemde.options.autosave.uniqueId);
//restart autosaving in case the submit will be cancelled down the line
setTimeout(function() {
simplemde.autosave();
}, 30000);
});
}
this.options.autosave.binded = true;
}
//...
};Should I create a pull request?
Metadata
Metadata
Assignees
Labels
No labels