Fix potential crash when dragging collection to another library

Fixes #141, Error dragging collection containing standalone note to library
where note isn't standalone
This commit is contained in:
Dan Stillman 2016-03-01 01:18:52 -05:00
parent d102e32f7d
commit 2b0aaf6314

View file

@ -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);
}
}