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.)
This commit is contained in:
parent
cbf4876173
commit
5a61ac4871
|
@ -2364,7 +2364,7 @@ Zotero.CollectionTreeRow.prototype.getSearchObject = Zotero.Promise.coroutine(fu
|
||||||
s.addCondition('deleted', 'true');
|
s.addCondition('deleted', 'true');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new Error('Invalid search mode in Zotero.CollectionTreeRow.getSearchObject()');
|
throw new Error('Invalid search mode ' + this.type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,9 +140,22 @@ Zotero.LibraryTreeView.prototype = {
|
||||||
if (lastRow && this.selection.isSelected(row)) {
|
if (lastRow && this.selection.isSelected(row)) {
|
||||||
// Deselect removed row
|
// Deselect removed row
|
||||||
this.selection.toggleSelect(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) {
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -415,9 +415,7 @@ describe("Zotero.CollectionTreeView", function() {
|
||||||
linked = yield attachment.getLinkedItem(group.libraryID);
|
linked = yield attachment.getLinkedItem(group.libraryID);
|
||||||
assert.equal(linked.id, treeRow.ref.id);
|
assert.equal(linked.id, treeRow.ref.id);
|
||||||
|
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
return group.eraseTx();
|
||||||
return group.erase();
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should not copy an item or its attachment to a group twice", function* () {
|
it("should not copy an item or its attachment to a group twice", function* () {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user