From 2b0aaf63143dbfc4e237e1778d7e92f1d73170b6 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 1 Mar 2016 01:18:52 -0500 Subject: [PATCH] Fix potential crash when dragging collection to another library Fixes #141, Error dragging collection containing standalone note to library where note isn't standalone --- chrome/content/zotero/xpcom/collectionTreeView.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js index e134111df..59b7a6f44 100644 --- a/chrome/content/zotero/xpcom/collectionTreeView.js +++ b/chrome/content/zotero/xpcom/collectionTreeView.js @@ -1667,6 +1667,18 @@ Zotero.CollectionTreeView.prototype.drop = function(row, orient, dataTransfer) if (!addItems[parent]) { addItems[parent] = []; } + + // If source item is a top-level non-regular item (which can exist in a + // collection) but target item is a child item (which can't), add target + // item's parent to collection instead + if (!item.isRegularItem()) { + let targetItem = Zotero.Items.get(id); + let targetItemParentID = targetItem.getSource(); + if (targetItemParentID) { + id = targetItemParentID; + } + } + addItems[parent].push(id); } }