Fix selected file not in view after searching again

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/15/head
trivernis 3 years ago
parent c6d4750013
commit b2500f362f
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -81,6 +81,7 @@ export class FileGridComponent implements OnChanges, OnInit, AfterViewInit, Afte
file => new Selectable<File>(file, false));
this.refreshFileSelections();
this.setPartitionedGridEntries();
this.scrollToSelection();
}
}
@ -246,7 +247,19 @@ export class FileGridComponent implements OnChanges, OnInit, AfterViewInit, Afte
selectedEntry.select();
this.selectedEntries.push(selectedEntry);
}
this.changeDetector.markForCheck();
}
}, 0);
}
}
private scrollToSelection() {
const selected = this.selectedEntries[0];
if (this.virtualScroll && selected) {
const index = Math.floor(this.gridEntries.indexOf(selected) / this.columns);
setTimeout(() => {
this.virtualScroll.scrollToIndex(index);
this.changeDetector.markForCheck();
}, 0);
}
}

Loading…
Cancel
Save