Skip to content

Commit

Permalink
Fix scrolling to resource in list when following resource link
Browse files Browse the repository at this point in the history
  • Loading branch information
tkleinke committed Jun 12, 2024
1 parent a167225 commit b804c14
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion desktop/src/app/components/resources/base-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export class BaseList {

public readonly itemSize: number;

private scrollTarget: FieldDocument;


constructor(public resourcesComponent: ResourcesComponent,
public viewFacade: ViewFacade,
Expand Down Expand Up @@ -71,11 +73,15 @@ export class BaseList {

if (!scrollTarget) return;

this.scrollTarget = scrollTarget;

const index = this.viewFacade.getDocuments()
.findIndex(document => document.resource.id === scrollTarget.resource.id);

if (!this.scrollViewport) {
setTimeout(() => this.scrollTo(scrollTarget, bottomElement), 100);
setTimeout(() => {
if (this.scrollTarget === scrollTarget) this.scrollTo(scrollTarget, bottomElement);
}, 100);
} else {
scrollTo(
index, 'resource-' + scrollTarget.resource.identifier, this.itemSize,
Expand Down

0 comments on commit b804c14

Please sign in to comment.