diff --git a/web/editor.js b/web/editor.js index 323c19e1a..387f10b97 100644 --- a/web/editor.js +++ b/web/editor.js @@ -24,6 +24,7 @@ function saveNow(keepFocus) { if (keepFocus) { saveField("key"); } else { + // triggers onBlur, which saves currentField.blur(); } } @@ -207,28 +208,28 @@ function caretToEnd() { } function onBlur() { - if (currentField) { - saveField("blur"); - clearChangeTimer(); + if (!currentField) { + return; } if (document.activeElement === currentField) { // other widget or window focused; current field unchanged - return; + saveField("key"); + } else { + saveField("blur"); + currentField = null; + disableButtons(); } - - currentField = null; - disableButtons(); } function saveField(type) { + clearChangeTimer(); if (!currentField) { // no field has been focused yet return; } // type is either 'blur' or 'key' pycmd(type + ":" + currentFieldOrdinal() + ":" + currentNoteId + ":" + currentField.innerHTML); - clearChangeTimer(); } function currentFieldOrdinal() {