Fix selection not being maintained when collapsing/expanding rows
This commit is contained in:
parent
55c758c9d0
commit
a2062bf011
4 changed files with 20 additions and 21 deletions
|
@ -2039,11 +2039,6 @@ var CollectionTree = class CollectionTree extends LibraryTree {
|
|||
if (!this.isContainerOpen(row) || this.isContainerEmpty(row)) return;
|
||||
|
||||
this.selection.selectEventsSuppressed = true;
|
||||
let selectParent = this.getParentIndex(this.selection.focused);
|
||||
while (selectParent != -1) {
|
||||
if (selectParent === row) this.selection.select(row);
|
||||
selectParent = this.getParentIndex(selectParent);
|
||||
}
|
||||
|
||||
var level = this.getLevel(row);
|
||||
var nextRow = row + 1;
|
||||
|
|
|
@ -56,7 +56,7 @@ module.exports = class {
|
|||
|
||||
this.scrollDirection = 0;
|
||||
this.scrollOffset = 0;
|
||||
this.overscanCount = 6;
|
||||
this.overscanCount = 2;
|
||||
this._lastItemCount = null;
|
||||
|
||||
Object.assign(this, options);
|
||||
|
|
|
@ -1708,6 +1708,9 @@ var ItemTree = class ItemTree extends LibraryTree {
|
|||
if (this.isContainerOpen(index)) {
|
||||
return this._closeContainer(index, skipRowMapRefresh);
|
||||
}
|
||||
if (!skipRowMapRefresh) {
|
||||
var savedSelection = this.getSelectedItems(true);
|
||||
}
|
||||
|
||||
var count = 0;
|
||||
var level = this.getLevel(index);
|
||||
|
@ -1753,11 +1756,12 @@ var ItemTree = class ItemTree extends LibraryTree {
|
|||
}
|
||||
|
||||
if (!skipRowMapRefresh) {
|
||||
await this._refreshPromise;
|
||||
this.tree.invalidate(index);
|
||||
|
||||
Zotero.debug('Refreshing item row map');
|
||||
this._refreshRowMap();
|
||||
|
||||
await this._refreshPromise;
|
||||
this._restoreSelection(savedSelection);
|
||||
this.tree.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1774,7 +1778,6 @@ var ItemTree = class ItemTree extends LibraryTree {
|
|||
this.toggleOpenState(i, true);
|
||||
}
|
||||
}
|
||||
this.tree && this.tree.invalidate();
|
||||
this._refreshRowMap();
|
||||
this._restoreSelection(savedSelection);
|
||||
}
|
||||
|
@ -2601,6 +2604,10 @@ var ItemTree = class ItemTree extends LibraryTree {
|
|||
if (!this.isContainer(index)) return;
|
||||
if (!this.isContainerOpen(index)) return;
|
||||
|
||||
if (!skipRowMapRefresh) {
|
||||
var savedSelection = this.getSelectedItems(true);
|
||||
}
|
||||
|
||||
var count = 0;
|
||||
var level = this.getLevel(index);
|
||||
|
||||
|
@ -2619,11 +2626,12 @@ var ItemTree = class ItemTree extends LibraryTree {
|
|||
}
|
||||
|
||||
if (!skipRowMapRefresh) {
|
||||
await this._refreshPromise;
|
||||
this.tree.invalidate(index);
|
||||
|
||||
Zotero.debug('Refreshing item row map');
|
||||
this._refreshRowMap();
|
||||
|
||||
await this._refreshPromise;
|
||||
this._restoreSelection(savedSelection, false);
|
||||
this.tree.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3057,12 +3065,12 @@ var ItemTree = class ItemTree extends LibraryTree {
|
|||
return;
|
||||
}
|
||||
|
||||
this.selection.clearSelection();
|
||||
|
||||
if (!this.selection.selectEventsSuppressed) {
|
||||
var unsuppress = this.selection.selectEventsSuppressed = true;
|
||||
}
|
||||
|
||||
this.selection.clearSelection();
|
||||
|
||||
let focusedSet = false;
|
||||
var toggleSelect = (function (itemID) {
|
||||
if (!focusedSet) {
|
||||
|
|
|
@ -148,12 +148,8 @@ var LibraryTree = class LibraryTree extends React.Component {
|
|||
var id = this.getRow(index).id;
|
||||
let level = this.getLevel(index);
|
||||
|
||||
let moveSelect = index - 1;
|
||||
if (index <= this.selection.pivot) {
|
||||
while (moveSelect >= this._rows.length) {
|
||||
moveSelect--;
|
||||
}
|
||||
this.selection.select(moveSelect);
|
||||
if (index <= this.selection.focused) {
|
||||
this.selection.select(this.selection.focused - 1);
|
||||
}
|
||||
|
||||
this._rows.splice(index, 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue