From 9ec9274011b6cace3e5f8323d482ffafd6c0b92a Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 1 Aug 2017 17:40:51 +1000 Subject: [PATCH] fix fields being overwritten when dropping remove the unneeded setFocus() call which was causing the blur event to fire with the wrong data --- aqt/editor.py | 3 +-- web/editor.js | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/aqt/editor.py b/aqt/editor.py index 565ac7f35..337428881 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -622,9 +622,8 @@ to a cloze type first, via Edit>Change Note Type.""")) self.web.eval("pasteHTML(%s);" % json.dumps(html)) def doDrop(self, html, internal): - self.web.evalWithCallback("dropTarget.focus();", + self.web.evalWithCallback("makeDropTargetCurrent();", lambda _: self.doPaste(html, internal)) - self.web.setFocus() def onPaste(self): self.web.onPaste() diff --git a/web/editor.js b/web/editor.js index bb393e8b8..8cea6eaf2 100644 --- a/web/editor.js +++ b/web/editor.js @@ -154,6 +154,10 @@ function onDragOver(elem) { dropTarget = elem; } +function makeDropTargetCurrent() { + dropTarget.focus(); +} + function onPaste(elem) { pycmd("paste"); window.event.preventDefault();