Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Commit 5ad187b

Browse files
committed
Ensure TOC scroll occurs after intial autofocus
1 parent c16dd46 commit 5ad187b

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

Diff for: src/app/pages/component-viewer/component-api.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
<doc-viewer
55
documentUrl="/assets/documents/api/{{componentViewer.componentDocItem.packageName}}-{{componentViewer.componentDocItem.id}}.html"
66
class="docs-component-view-text-content docs-component-api"
7-
(contentLoaded)="toc.createLinksAndScroll()"></doc-viewer>
7+
(contentLoaded)="focusInitialTarget(); toc.createLinksAndScroll()"></doc-viewer>
88
<table-of-contents #toc headerSelectors=".docs-api-h3,.docs-api-h4"></table-of-contents>

Diff for: src/app/pages/component-viewer/component-overview.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
<doc-viewer
55
documentUrl="/assets/documents/overview/{{componentViewer.componentDocItem.packageName}}-{{componentViewer.componentDocItem.id}}.html"
66
class="docs-component-view-text-content docs-component-overview"
7-
(contentLoaded)="toc.createLinksAndScroll()">
7+
(contentLoaded)="focusInitialTarget(); toc.createLinksAndScroll()">
88
</doc-viewer>
99
<table-of-contents #toc></table-of-contents>

Diff for: src/app/pages/component-viewer/component-viewer.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, OnInit, NgModule, ElementRef, ViewEncapsulation, ViewChild} from '@angular/core';
1+
import {Component, NgModule, ElementRef, ViewEncapsulation, ViewChild} from '@angular/core';
22
import {ActivatedRoute, Params, Router, RouterModule} from '@angular/router';
33
import {DocumentationItems, DocItem} from '../../shared/documentation-items/documentation-items';
44
import {ComponentPageTitle} from '../page-title/page-title';
@@ -49,14 +49,13 @@ export class ComponentViewer {
4949
templateUrl: './component-overview.html',
5050
encapsulation: ViewEncapsulation.None,
5151
})
52-
export class ComponentOverview implements OnInit {
52+
export class ComponentOverview {
5353
@ViewChild('intialFocusTarget') focusTarget: ElementRef;
5454

5555
constructor(public componentViewer: ComponentViewer) {}
5656

57-
ngOnInit() {
58-
// 100ms timeout is used to allow the page to settle before moving focus for screen readers.
59-
setTimeout(() => this.focusTarget.nativeElement.focus(), 100);
57+
focusInitialTarget() {
58+
this.focusTarget.nativeElement.focus();
6059
}
6160
}
6261

0 commit comments

Comments
 (0)