collection search not focusing group on Enter fix

While looking for the first matching row to select, stop looking
and move focus to the tree only after the selection succeeded.
Some matching rows, like groups header, are not selectable. If it's the
first matching row, it will now be skipped.
This commit is contained in:
abaevbog 2023-12-11 04:35:26 -05:00 committed by Dan Stillman
parent f454e110ec
commit a2e034c921

View file

@ -2446,18 +2446,27 @@ var CollectionTree = class CollectionTree extends LibraryTree {
async focusFirstMatchingRow(scrollToLibrary) {
let index = 0;
let row = this.getRow(index);
while (index < this._rows.length && !this._matchesFilter(row.ref).matchesFilter) {
while (index < this._rows.length) {
row = this.getRow(index);
if (!row.isOpen) {
if (this._matchesFilter(row.ref).matchesFilter) {
// The matching row may not be selectable (e.g. Group Libraries header).
// In that case, just keep looking for the next row
let wasSelected = await this.selectByID(row.id);
if (wasSelected) {
// If selection happened, move focus onto the tree
this.tree.focus();
if (scrollToLibrary) {
this.ensureRowIsVisible(0);
}
return;
}
}
// Selection did not happen - keep going. Open any containers on the way
if (!this.isContainerOpen(index)) {
await this.toggleOpenState(index);
}
index += 1;
}
this.tree.focus();
await this.selectByID(row.id);
if (scrollToLibrary) {
this.ensureRowIsVisible(0);
}
}
/**