diff --git a/src/lib/sidenav/drawer.spec.ts b/src/lib/sidenav/drawer.spec.ts index 0219941c64f..70cf24896b7 100644 --- a/src/lib/sidenav/drawer.spec.ts +++ b/src/lib/sidenav/drawer.spec.ts @@ -411,15 +411,17 @@ describe('MatDrawer', () => { beforeEach(() => { fixture = TestBed.createComponent(DrawerWithFocusableElements); + fixture.detectChanges(); testComponent = fixture.debugElement.componentInstance; drawer = fixture.debugElement.query(By.directive(MatDrawer)).componentInstance; - firstFocusableElement = fixture.debugElement.query(By.css('.link1')).nativeElement; - lastFocusableElement = fixture.debugElement.query(By.css('.link1')).nativeElement; + firstFocusableElement = fixture.debugElement.query(By.css('.input1')).nativeElement; + lastFocusableElement = fixture.debugElement.query(By.css('.input2')).nativeElement; lastFocusableElement.focus(); }); it('should trap focus when opened in "over" mode', fakeAsync(() => { testComponent.mode = 'over'; + fixture.detectChanges(); lastFocusableElement.focus(); drawer.open(); @@ -431,6 +433,7 @@ describe('MatDrawer', () => { it('should trap focus when opened in "push" mode', fakeAsync(() => { testComponent.mode = 'push'; + fixture.detectChanges(); lastFocusableElement.focus(); drawer.open(); @@ -442,6 +445,7 @@ describe('MatDrawer', () => { it('should not trap focus when opened in "side" mode', fakeAsync(() => { testComponent.mode = 'side'; + fixture.detectChanges(); lastFocusableElement.focus(); drawer.open(); @@ -717,12 +721,14 @@ class DrawerDynamicPosition { } @Component({ + // Note: we use inputs here, because they're guaranteed + // to be focusable across all platforms. template: ` - link1 + - link2 + `, }) class DrawerWithFocusableElements {