Skip to content

Commit a779017

Browse files
crisbetojosephperrott
authored andcommitted
build: safari focus trapping test failures (#9075)
1 parent 9a856d7 commit a779017

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/lib/sidenav/drawer.spec.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,15 +411,17 @@ describe('MatDrawer', () => {
411411

412412
beforeEach(() => {
413413
fixture = TestBed.createComponent(DrawerWithFocusableElements);
414+
fixture.detectChanges();
414415
testComponent = fixture.debugElement.componentInstance;
415416
drawer = fixture.debugElement.query(By.directive(MatDrawer)).componentInstance;
416-
firstFocusableElement = fixture.debugElement.query(By.css('.link1')).nativeElement;
417-
lastFocusableElement = fixture.debugElement.query(By.css('.link1')).nativeElement;
417+
firstFocusableElement = fixture.debugElement.query(By.css('.input1')).nativeElement;
418+
lastFocusableElement = fixture.debugElement.query(By.css('.input2')).nativeElement;
418419
lastFocusableElement.focus();
419420
});
420421

421422
it('should trap focus when opened in "over" mode', fakeAsync(() => {
422423
testComponent.mode = 'over';
424+
fixture.detectChanges();
423425
lastFocusableElement.focus();
424426

425427
drawer.open();
@@ -431,6 +433,7 @@ describe('MatDrawer', () => {
431433

432434
it('should trap focus when opened in "push" mode', fakeAsync(() => {
433435
testComponent.mode = 'push';
436+
fixture.detectChanges();
434437
lastFocusableElement.focus();
435438

436439
drawer.open();
@@ -442,6 +445,7 @@ describe('MatDrawer', () => {
442445

443446
it('should not trap focus when opened in "side" mode', fakeAsync(() => {
444447
testComponent.mode = 'side';
448+
fixture.detectChanges();
445449
lastFocusableElement.focus();
446450

447451
drawer.open();
@@ -717,12 +721,14 @@ class DrawerDynamicPosition {
717721
}
718722

719723
@Component({
724+
// Note: we use inputs here, because they're guaranteed
725+
// to be focusable across all platforms.
720726
template: `
721727
<mat-drawer-container>
722728
<mat-drawer position="start" [mode]="mode">
723-
<a class="link1" href="#">link1</a>
729+
<input type="text" class="input1"/>
724730
</mat-drawer>
725-
<a class="link2" href="#">link2</a>
731+
<input type="text" class="input2"/>
726732
</mat-drawer-container>`,
727733
})
728734
class DrawerWithFocusableElements {

0 commit comments

Comments
 (0)