@@ -307,6 +307,28 @@ describe('MatDrawer', () => {
307
307
. toBe ( openButton , 'Expected focus to be restored to the open button on close.' ) ;
308
308
} ) ) ;
309
309
310
+ it ( 'should restore focus to an SVG element' , fakeAsync ( ( ) => {
311
+ const fixture = TestBed . createComponent ( BasicTestApp ) ;
312
+ fixture . detectChanges ( ) ;
313
+
314
+ const drawer = fixture . debugElement . query ( By . directive ( MatDrawer ) ) ! . componentInstance ;
315
+ const svg = fixture . componentInstance . svg . nativeElement ;
316
+ const drawerButton = fixture . componentInstance . drawerButton . nativeElement ;
317
+
318
+ svg . focus ( ) ;
319
+ drawer . open ( ) ;
320
+ fixture . detectChanges ( ) ;
321
+ flush ( ) ;
322
+ drawerButton . focus ( ) ;
323
+
324
+ drawer . close ( ) ;
325
+ fixture . detectChanges ( ) ;
326
+ flush ( ) ;
327
+
328
+ expect ( document . activeElement )
329
+ . toBe ( svg , 'Expected focus to be restored to the SVG element on close.' ) ;
330
+ } ) ) ;
331
+
310
332
it ( 'should not restore focus on close if focus is outside drawer' , fakeAsync ( ( ) => {
311
333
let fixture = TestBed . createComponent ( BasicTestApp ) ;
312
334
let drawer : MatDrawer = fixture . debugElement
@@ -907,6 +929,9 @@ class DrawerContainerTwoDrawerTestApp {
907
929
</mat-drawer>
908
930
<button (click)="drawer.open()" class="open" #openButton></button>
909
931
<button (click)="drawer.close()" class="close" #closeButton></button>
932
+ <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" tabindex="0" #svg>
933
+ <circle cx="50" cy="50" r="50"/>
934
+ </svg>
910
935
</mat-drawer-container>` ,
911
936
} )
912
937
class BasicTestApp {
@@ -920,6 +945,7 @@ class BasicTestApp {
920
945
@ViewChild ( 'drawer' ) drawer : MatDrawer ;
921
946
@ViewChild ( 'drawerButton' ) drawerButton : ElementRef < HTMLButtonElement > ;
922
947
@ViewChild ( 'openButton' ) openButton : ElementRef < HTMLButtonElement > ;
948
+ @ViewChild ( 'svg' ) svg : ElementRef < SVGElement > ;
923
949
@ViewChild ( 'closeButton' ) closeButton : ElementRef < HTMLButtonElement > ;
924
950
925
951
open ( ) {
0 commit comments