File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
universal-app/kitchen-sink Expand file tree Collapse file tree 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 {
140140 */
141141 focusVia ( element : HTMLElement , origin : FocusOrigin ) : void {
142142 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+ }
144148 }
145149
146150 ngOnDestroy ( ) {
Original file line number Diff line number Diff line change 33 CdkTableModule ,
44 DataSource
55} from '@angular/cdk/table' ;
6- import { Component , NgModule } from '@angular/core' ;
6+ import { Component , ElementRef , NgModule } from '@angular/core' ;
77import {
88 MatAutocompleteModule ,
99 MatBadgeModule ,
@@ -44,6 +44,7 @@ import {
4444} from '@angular/material' ;
4545import { BrowserModule } from '@angular/platform-browser' ;
4646import { ServerModule } from '@angular/platform-server' ;
47+ import { FocusMonitor } from '@angular/cdk/a11y' ;
4748import { Observable , of as observableOf } from 'rxjs' ;
4849
4950export class TableDataSource extends DataSource < any > {
@@ -77,7 +78,10 @@ export class KitchenSink {
7778 constructor (
7879 snackBar : MatSnackBar ,
7980 dialog : MatDialog ,
80- viewportRuler : ViewportRuler ) {
81+ viewportRuler : ViewportRuler ,
82+ focusMonitor : FocusMonitor ,
83+ elementRef : ElementRef < HTMLElement > ) {
84+ focusMonitor . focusVia ( elementRef . nativeElement , 'program' ) ;
8185 snackBar . open ( 'Hello there' ) ;
8286 dialog . open ( TestDialog ) ;
8387
You can’t perform that action at this time.
0 commit comments