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

Commit 57a3d76

Browse files
committed
Ensure TOC scroll occurs after intial autofocus
1 parent 0a0f46c commit 57a3d76

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,5 +1,5 @@
11
import {CommonModule} from '@angular/common';
2-
import {Component, ElementRef, NgModule, OnInit, ViewChild, ViewEncapsulation} from '@angular/core';
2+
import {Component, ElementRef, NgModule, ViewChild, ViewEncapsulation} from '@angular/core';
33
import {MatTabsModule} from '@angular/material';
44
import {ActivatedRoute, Params, Router, RouterModule} from '@angular/router';
55
import 'rxjs/add/operator/map';
@@ -50,14 +50,13 @@ export class ComponentViewer {
5050
templateUrl: './component-overview.html',
5151
encapsulation: ViewEncapsulation.None,
5252
})
53-
export class ComponentOverview implements OnInit {
53+
export class ComponentOverview {
5454
@ViewChild('intialFocusTarget') focusTarget: ElementRef;
5555

5656
constructor(public componentViewer: ComponentViewer) {}
5757

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

0 commit comments

Comments
 (0)