forked from angular/components
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Focus page content after navigation for a11y. (angular#267)
- Loading branch information
1 parent
62706dc
commit b6da10c
Showing
9 changed files
with
56 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,5 @@ | |
<md-icon>menu</md-icon> | ||
</button> | ||
|
||
<h1>{{getTitle()}} </h1> | ||
<h1 focusOnNavigation>{{getTitle()}} </h1> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
<doc-viewer | ||
documentUrl="/assets/documents/api/{{componentViewer.componentDocItem.id}}.html" | ||
class="docs-component-view-text-content"></doc-viewer> | ||
<span class="cdk-visually-hidden" tabindex="-1" #intialFocusTarget> | ||
API for {{componentViewer.componentDocItem.id}} | ||
</span> | ||
<doc-viewer | ||
documentUrl="/assets/documents/api/{{componentViewer.componentDocItem.id}}.html" | ||
class="docs-component-view-text-content"></doc-viewer> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
<span class="cdk-visually-hidden" tabindex="-1" #intialFocusTarget> | ||
Examples for {{componentViewer.componentDocItem.id}} | ||
</span> | ||
<example-viewer | ||
*ngFor="let example of componentViewer.componentDocItem.examples" | ||
[example]="example"></example-viewer> | ||
*ngFor="let example of componentViewer.componentDocItem.examples" | ||
[example]="example"></example-viewer> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import {NgModule, Injectable, OnInit, Directive, Input, ElementRef, Renderer2} from '@angular/core'; | ||
import {Subscription} from 'rxjs/Subscription'; | ||
|
||
/** The timeout id of the previous focus change. */ | ||
let lastTimeoutId = -1; | ||
|
||
@Directive({ | ||
selector: '[focusOnNavigation]', | ||
host: {'tabindex': '-1'}, | ||
}) | ||
export class NavigationFocus implements OnInit { | ||
constructor(private el: ElementRef) {} | ||
|
||
ngOnInit() { | ||
clearTimeout(lastTimeoutId); | ||
// 100ms timeout is used to allow the page to settle before moving focus for screen readers. | ||
lastTimeoutId = setTimeout(() => this.el.nativeElement.focus(), 100); | ||
} | ||
} | ||
|
||
@NgModule({ | ||
declarations: [NavigationFocus], | ||
exports: [NavigationFocus], | ||
}) | ||
export class NavigationFocusModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters