From 844778636c913c9a53ff002ce2cb577d67e97248 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 30 Apr 2018 15:26:54 +1000 Subject: [PATCH] preserve cursor position when switching to another window https://anki.tenderapp.com/discussions/beta-testing/1043-anki-21-beta-37-if-switch-from-another-program-to-continue-editing-the-cursor-will-move-to-the-bottom --- web/editor.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/web/editor.js b/web/editor.js index 5295837a8..41ecea077 100644 --- a/web/editor.js +++ b/web/editor.js @@ -120,6 +120,10 @@ function clearChangeTimer() { } function onFocus(elem) { + if (currentField === elem) { + // anki window refocused; current element unchanged + return; + } currentField = elem; pycmd("focus:" + currentFieldOrdinal()); enableButtons(); @@ -190,6 +194,10 @@ function caretToEnd() { } function onBlur() { + if (document.activeElement === currentField) { + // anki window defocused; current field unchanged + return; + } if (currentField) { saveField("blur"); currentField = null;