From 5fa979575e53bd1cf25e1f1847c0048356b5565d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Tue, 31 Dec 2019 11:35:13 +0200 Subject: [PATCH] Fix quick format bubble drag-and-drop (see 5a1e3296) --- chrome/content/zotero/integration/quickFormat.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/chrome/content/zotero/integration/quickFormat.js b/chrome/content/zotero/integration/quickFormat.js index 9b181f8f41..8dfbefcbae 100644 --- a/chrome/content/zotero/integration/quickFormat.js +++ b/chrome/content/zotero/integration/quickFormat.js @@ -1252,7 +1252,7 @@ var Zotero_QuickFormat = new function () { function _getBubbleIndex(bubble) { var nodes = qfe.childNodes, index = 0; for (let node of nodes) { - if (node.dataset.citationItem) { + if (node.dataset && node.dataset.citationItem) { if (node == bubble) return index; index++; } @@ -1267,13 +1267,14 @@ var Zotero_QuickFormat = new function () { event.preventDefault(); event.stopPropagation(); - var range = document.createRange(); - // Find old position in list var oldPosition = _getBubbleIndex(dragging); - range.setStart(event.rangeParent, event.rangeOffset); + + // Move bubble + var range = document.createRange(); + range.setStartBefore(event.rangeParent); dragging.parentNode.removeChild(dragging); - var bubble = _insertBubble(dragging.citationItem, range); + var bubble = _insertBubble(JSON.parse(dragging.dataset.citationItem), range); // If moved out of order, turn off "Keep Sources Sorted" if(io.sortable && keepSorted.hasAttribute("checked") && oldPosition !== -1 &&