Skip to content

Commit ed735a1

Browse files
tinayuangaojelbourn
authored andcommitted
chore: add skip navigation link for a11y demo (#6423)
1 parent 8f9f3c8 commit ed735a1

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/demo-app/a11y/a11y.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
<h1>Accessibility Demo</h1>
22

33
<nav>
4+
<a (click)="skipNavigation()" href="javascript:void(0)">Skip navigation</a>
45
<a *ngFor="let navItem of navItems" [routerLink]="[navItem.route]">
56
{{navItem.name}}
67
</a>
78
</nav>
89

9-
<router-outlet></router-outlet>
10+
<div #maincontent tabindex="0">
11+
<router-outlet></router-outlet>
12+
</div>

src/demo-app/a11y/a11y.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, ViewEncapsulation} from '@angular/core';
1+
import {Component, ElementRef, ViewChild, ViewEncapsulation} from '@angular/core';
22

33
@Component({
44
moduleId: module.id,
@@ -15,6 +15,8 @@ export class AccessibilityHome {}
1515
encapsulation: ViewEncapsulation.None,
1616
})
1717
export class AccessibilityDemo {
18+
@ViewChild('maincontent') mainContent: ElementRef;
19+
1820
navItems = [
1921
{name: 'Home', route: '.'},
2022
{name: 'Autocomplete', route: 'autocomplete'},
@@ -37,4 +39,9 @@ export class AccessibilityDemo {
3739
{name: 'Select', route: 'select'},
3840
{name: 'Toolbar', route: 'toolbar'},
3941
];
42+
43+
skipNavigation() {
44+
this.mainContent.nativeElement.scrollIntoView();
45+
this.mainContent.nativeElement.focus();
46+
}
4047
}

0 commit comments

Comments
 (0)