@@ -307,6 +307,28 @@ describe('MatDrawer', () => {
307307 . toBe ( openButton , 'Expected focus to be restored to the open button on close.' ) ;
308308 } ) ) ;
309309
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+
310332 it ( 'should not restore focus on close if focus is outside drawer' , fakeAsync ( ( ) => {
311333 let fixture = TestBed . createComponent ( BasicTestApp ) ;
312334 let drawer : MatDrawer = fixture . debugElement
@@ -907,6 +929,14 @@ class DrawerContainerTwoDrawerTestApp {
907929 </mat-drawer>
908930 <button (click)="drawer.open()" class="open" #openButton></button>
909931 <button (click)="drawer.close()" class="close" #closeButton></button>
932+ <svg
933+ viewBox="0 0 100 100"
934+ xmlns="http://www.w3.org/2000/svg"
935+ tabindex="0"
936+ focusable="true"
937+ #svg>
938+ <circle cx="50" cy="50" r="50"/>
939+ </svg>
910940 </mat-drawer-container>` ,
911941} )
912942class BasicTestApp {
@@ -920,6 +950,7 @@ class BasicTestApp {
920950 @ViewChild ( 'drawer' ) drawer : MatDrawer ;
921951 @ViewChild ( 'drawerButton' ) drawerButton : ElementRef < HTMLButtonElement > ;
922952 @ViewChild ( 'openButton' ) openButton : ElementRef < HTMLButtonElement > ;
953+ @ViewChild ( 'svg' ) svg : ElementRef < SVGElement > ;
923954 @ViewChild ( 'closeButton' ) closeButton : ElementRef < HTMLButtonElement > ;
924955
925956 open ( ) {
0 commit comments