diff --git a/src/app/about/chipped-content/chipped-content.component.ts b/src/app/about/chipped-content/chipped-content.component.ts index de6e830e..7e46c9ff 100644 --- a/src/app/about/chipped-content/chipped-content.component.ts +++ b/src/app/about/chipped-content/chipped-content.component.ts @@ -60,20 +60,24 @@ export class ChippedContentComponent implements OnInit { } async setSelectedContent(id: string) { + const content = this.contents.find((content) => content.id === id)! + this.contentHost.clear() + // Tapping same chip hides content if (this.selectedContentId === id) { - const content = this.contents.find((content) => content.id === id)! - this.contentHost.clear() this.selectedContentId = undefined await content.waitForAnimationEnd(this.selectedContentComponent) this.contentDisplayedChange.emit(false) return } + this.selectedContentId = id - this.contentHost.clear() - const content = this.contents.find((content) => content.id === id)! - this.addContentToHost(content) + const componentRef = this.addContentToHost(content) this.contentDisplayedChange.emit(true) + await content.waitForAnimationEnd(componentRef.instance) + ;(componentRef.location.nativeElement as HTMLElement).scrollIntoView({ + block: 'nearest', + }) } private hideContentElement(elementRef: ElementRef) {