@@ -622,7 +622,7 @@ describe('MatBottomSheet', () => {
622
622
beforeEach ( ( ) => document . body . appendChild ( overlayContainerElement ) ) ;
623
623
afterEach ( ( ) => overlayContainerElement . remove ( ) ) ;
624
624
625
- it ( 'should focus the bottom sheet container by default' , fakeAsync ( ( ) => {
625
+ it ( 'should focus the first tabbable element by default' , fakeAsync ( ( ) => {
626
626
bottomSheet . open ( PizzaMsg , {
627
627
viewContainerRef : testViewContainerRef ,
628
628
} ) ;
@@ -631,9 +631,7 @@ describe('MatBottomSheet', () => {
631
631
flush ( ) ;
632
632
viewContainerFixture . detectChanges ( ) ;
633
633
634
- expect ( document . activeElement ! . tagName )
635
- . withContext ( 'Expected bottom sheet container to be focused.' )
636
- . toBe ( 'MAT-BOTTOM-SHEET-CONTAINER' ) ;
634
+ expect ( document . activeElement ! . tagName ) . toBe ( 'INPUT' ) ;
637
635
} ) ) ;
638
636
639
637
it ( 'should create a focus trap if autoFocus is disabled' , fakeAsync ( ( ) => {
@@ -669,72 +667,62 @@ describe('MatBottomSheet', () => {
669
667
} ,
670
668
) ;
671
669
672
- it (
673
- 'should focus the bottom sheet element on open when autoFocus is set to ' +
674
- '"dialog" (the default)' ,
675
- fakeAsync ( ( ) => {
676
- bottomSheet . open ( PizzaMsg , {
677
- viewContainerRef : testViewContainerRef ,
678
- } ) ;
670
+ it ( 'should focus the bottom sheet element on open when autoFocus is set to "dialog"' , fakeAsync ( ( ) => {
671
+ bottomSheet . open ( PizzaMsg , {
672
+ viewContainerRef : testViewContainerRef ,
673
+ autoFocus : 'dialog' ,
674
+ } ) ;
679
675
680
- viewContainerFixture . detectChanges ( ) ;
681
- flush ( ) ;
682
- viewContainerFixture . detectChanges ( ) ;
676
+ viewContainerFixture . detectChanges ( ) ;
677
+ flush ( ) ;
678
+ viewContainerFixture . detectChanges ( ) ;
683
679
684
- let container = overlayContainerElement . querySelector (
685
- '.mat-bottom-sheet-container' ,
686
- ) as HTMLInputElement ;
680
+ let container = overlayContainerElement . querySelector (
681
+ '.mat-bottom-sheet-container' ,
682
+ ) as HTMLInputElement ;
687
683
688
- expect ( document . activeElement )
689
- . withContext ( 'Expected container to be focused on open' )
690
- . toBe ( container ) ;
691
- } ) ,
692
- ) ;
684
+ expect ( document . activeElement )
685
+ . withContext ( 'Expected container to be focused on open' )
686
+ . toBe ( container ) ;
687
+ } ) ) ;
693
688
694
- it (
695
- 'should focus the bottom sheet element on open when autoFocus is set to ' + '"first-heading"' ,
696
- fakeAsync ( ( ) => {
697
- bottomSheet . open ( ContentElementDialog , {
698
- viewContainerRef : testViewContainerRef ,
699
- autoFocus : 'first-heading' ,
700
- } ) ;
689
+ it ( 'should focus the bottom sheet element on open when autoFocus is set to "first-heading"' , fakeAsync ( ( ) => {
690
+ bottomSheet . open ( ContentElementDialog , {
691
+ viewContainerRef : testViewContainerRef ,
692
+ autoFocus : 'first-heading' ,
693
+ } ) ;
701
694
702
- viewContainerFixture . detectChanges ( ) ;
703
- flush ( ) ;
704
- viewContainerFixture . detectChanges ( ) ;
695
+ viewContainerFixture . detectChanges ( ) ;
696
+ flush ( ) ;
697
+ viewContainerFixture . detectChanges ( ) ;
705
698
706
- let firstHeader = overlayContainerElement . querySelector (
707
- 'h1[tabindex="-1"]' ,
708
- ) as HTMLInputElement ;
699
+ let firstHeader = overlayContainerElement . querySelector (
700
+ 'h1[tabindex="-1"]' ,
701
+ ) as HTMLInputElement ;
709
702
710
- expect ( document . activeElement )
711
- . withContext ( 'Expected first header to be focused on open' )
712
- . toBe ( firstHeader ) ;
713
- } ) ,
714
- ) ;
703
+ expect ( document . activeElement )
704
+ . withContext ( 'Expected first header to be focused on open' )
705
+ . toBe ( firstHeader ) ;
706
+ } ) ) ;
715
707
716
- it (
717
- 'should focus the first element that matches the css selector on open when ' +
718
- 'autoFocus is set to a css selector' ,
719
- fakeAsync ( ( ) => {
720
- bottomSheet . open ( ContentElementDialog , {
721
- viewContainerRef : testViewContainerRef ,
722
- autoFocus : 'p' ,
723
- } ) ;
708
+ it ( 'should focus the first element that matches the css selector on open when autoFocus is set to a css selector' , fakeAsync ( ( ) => {
709
+ bottomSheet . open ( ContentElementDialog , {
710
+ viewContainerRef : testViewContainerRef ,
711
+ autoFocus : 'p' ,
712
+ } ) ;
724
713
725
- viewContainerFixture . detectChanges ( ) ;
726
- flush ( ) ;
727
- viewContainerFixture . detectChanges ( ) ;
714
+ viewContainerFixture . detectChanges ( ) ;
715
+ flush ( ) ;
716
+ viewContainerFixture . detectChanges ( ) ;
728
717
729
- let firstParagraph = overlayContainerElement . querySelector (
730
- 'p[tabindex="-1"]' ,
731
- ) as HTMLInputElement ;
718
+ let firstParagraph = overlayContainerElement . querySelector (
719
+ 'p[tabindex="-1"]' ,
720
+ ) as HTMLInputElement ;
732
721
733
- expect ( document . activeElement )
734
- . withContext ( 'Expected first paragraph to be focused on open' )
735
- . toBe ( firstParagraph ) ;
736
- } ) ,
737
- ) ;
722
+ expect ( document . activeElement )
723
+ . withContext ( 'Expected first paragraph to be focused on open' )
724
+ . toBe ( firstParagraph ) ;
725
+ } ) ) ;
738
726
739
727
it ( 'should re-focus trigger element when bottom sheet closes' , fakeAsync ( ( ) => {
740
728
const button = document . createElement ( 'button' ) ;
0 commit comments