File tree 2 files changed +11
-3
lines changed
universal-app/kitchen-sink 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -140,7 +140,11 @@ export class FocusMonitor implements OnDestroy {
140
140
*/
141
141
focusVia ( element : HTMLElement , origin : FocusOrigin ) : void {
142
142
this . _setOriginForCurrentEventQueue ( origin ) ;
143
- element . focus ( ) ;
143
+
144
+ // `focus` isn't available on the server
145
+ if ( typeof element . focus === 'function' ) {
146
+ element . focus ( ) ;
147
+ }
144
148
}
145
149
146
150
ngOnDestroy ( ) {
Original file line number Diff line number Diff line change 3
3
CdkTableModule ,
4
4
DataSource
5
5
} from '@angular/cdk/table' ;
6
- import { Component , NgModule } from '@angular/core' ;
6
+ import { Component , ElementRef , NgModule } from '@angular/core' ;
7
7
import {
8
8
MatAutocompleteModule ,
9
9
MatBadgeModule ,
@@ -44,6 +44,7 @@ import {
44
44
} from '@angular/material' ;
45
45
import { BrowserModule } from '@angular/platform-browser' ;
46
46
import { ServerModule } from '@angular/platform-server' ;
47
+ import { FocusMonitor } from '@angular/cdk/a11y' ;
47
48
import { Observable , of as observableOf } from 'rxjs' ;
48
49
49
50
export class TableDataSource extends DataSource < any > {
@@ -77,7 +78,10 @@ export class KitchenSink {
77
78
constructor (
78
79
snackBar : MatSnackBar ,
79
80
dialog : MatDialog ,
80
- viewportRuler : ViewportRuler ) {
81
+ viewportRuler : ViewportRuler ,
82
+ focusMonitor : FocusMonitor ,
83
+ elementRef : ElementRef < HTMLElement > ) {
84
+ focusMonitor . focusVia ( elementRef . nativeElement , 'program' ) ;
81
85
snackBar . open ( 'Hello there' ) ;
82
86
dialog . open ( TestDialog ) ;
83
87
You can’t perform that action at this time.
0 commit comments