diff --git a/mediarepo-ui/src/app/components/shared/file/file-multiview/file-grid/file-grid.component.ts b/mediarepo-ui/src/app/components/shared/file/file-multiview/file-grid/file-grid.component.ts index d4ecf5e..e7569d0 100644 --- a/mediarepo-ui/src/app/components/shared/file/file-multiview/file-grid/file-grid.component.ts +++ b/mediarepo-ui/src/app/components/shared/file/file-multiview/file-grid/file-grid.component.ts @@ -81,6 +81,7 @@ export class FileGridComponent implements OnChanges, OnInit, AfterViewInit, Afte file => new Selectable(file, false)); this.refreshFileSelections(); this.setPartitionedGridEntries(); + this.scrollToSelection(); } } @@ -246,11 +247,23 @@ 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); + } + } + private refreshFileSelections() { const newSelection: Selectable[] = this.gridEntries.filter( entry => this.selectedEntries.findIndex(