commit 5a61ac48715f554426e700716de4e87227636f79
parent cbf4876173974398ee921a4739210e4159d092ab
Author: Dan Stillman <dstillman@zotero.org>
Date: Fri, 7 Aug 2015 16:36:53 -0400
Don't try to select unselectable row on library tree row removal
(If deleting a group, don't select the header or separator before it.)
Diffstat:
3 files changed, 17 insertions(+), 6 deletions(-)
diff --git 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
@@ -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
@@ -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* () {