Fix item tree crash on Cmd-left-arrow under certain conditions

If a parent item was expanded and all items in the tree, including the
item's child items, were selected, Cmd + Left Arrow would break the
items tree until restart.

This will cause a conflict and need to be applied to the new tree.

(Worth noting that collapseSelectedRows() is currently only called on
Cmd-left-arrow because the XUL tree seemingly swallows a regular
left-arrow (and only applies the collapse to the last-selected row). The
comment in the keypress listener where collapseSelectedRows() is called
suggests that that was meant to be used for all left-arrow keypresses,
but either that stopped working at some point or it only ever worked for
Cmd + Left Arrow because it bypasses the normal tree handling of left-
arrow. In any case, it would be better if left-arrow always collapsed
selected rows, with or without Cmd.)

https://forums.zotero.org/discussion/78515/bug-collapsing-all-items-in-a-collection-breaks-display-of-items-in-all-collections
This commit is contained in:
Dan Stillman 2019-08-04 01:38:46 -04:00
parent c2e79c0717
commit 77467b94da

View file

@ -2354,7 +2354,7 @@ Zotero.ItemTreeView.prototype.collapseSelectedRows = function () {
this._treebox.beginUpdateBatch();
for (var i = 0, len = this.selection.getRangeCount(); i<len; i++) {
this.selection.getRangeAt(i, start, end);
for (var j = start.value; j <= end.value; j++) {
for (let j = end.value; j >= start.value; j--) {
if (this.isContainer(j)) {
this._closeContainer(j, true);
}