diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js index a6af173a6..d4f0bbd83 100644 --- a/chrome/content/zotero/xpcom/collectionTreeView.js +++ b/chrome/content/zotero/xpcom/collectionTreeView.js @@ -2364,7 +2364,7 @@ Zotero.CollectionTreeRow.prototype.getSearchObject = Zotero.Promise.coroutine(fu s.addCondition('deleted', 'true'); } else { - throw new Error('Invalid search mode in Zotero.CollectionTreeRow.getSearchObject()'); + throw new Error('Invalid search mode ' + this.type); } } diff --git a/chrome/content/zotero/xpcom/libraryTreeView.js b/chrome/content/zotero/xpcom/libraryTreeView.js index a2397f3f2..ede36d300 100644 --- a/chrome/content/zotero/xpcom/libraryTreeView.js +++ b/chrome/content/zotero/xpcom/libraryTreeView.js @@ -140,9 +140,22 @@ Zotero.LibraryTreeView.prototype = { if (lastRow && this.selection.isSelected(row)) { // Deselect removed row this.selection.toggleSelect(row); - // If no other rows selected, select row before + // If no other rows selected, select first selectable row before if (this.selection.count == 0 && row !== 0) { - this.selection.toggleSelect(row - 1); + let previous = row; + while (true) { + previous--; + // Should ever happen + if (previous < 0) { + break; + } + if (!this.isSelectable(previous)) { + continue; + } + + this.selection.toggleSelect(previous); + break; + } } } diff --git a/test/tests/collectionTreeViewTest.js b/test/tests/collectionTreeViewTest.js index 3adc25bba..4ad3ea0be 100644 --- a/test/tests/collectionTreeViewTest.js +++ b/test/tests/collectionTreeViewTest.js @@ -415,9 +415,7 @@ describe("Zotero.CollectionTreeView", function() { linked = yield attachment.getLinkedItem(group.libraryID); assert.equal(linked.id, treeRow.ref.id); - yield Zotero.DB.executeTransaction(function* () { - return group.erase(); - }) + return group.eraseTx(); }) it("should not copy an item or its attachment to a group twice", function* () {