File tree Expand file tree Collapse file tree 2 files changed +12
-11
lines changed Expand file tree Collapse file tree 2 files changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -283,13 +283,17 @@ export class CdkDialogContainer<C extends DialogConfig = DialogConfig>
283
283
break ;
284
284
case true :
285
285
case 'first-tabbable' :
286
- this . _focusTrap ?. focusInitialElementWhenReady ( ) . then ( focusedSuccessfully => {
287
- // If we weren't able to find a focusable element in the dialog, then focus the dialog
288
- // container instead.
289
- if ( ! focusedSuccessfully ) {
290
- this . _focusDialogContainer ( ) ;
291
- }
292
- } ) ;
286
+ afterNextRender (
287
+ ( ) => {
288
+ const focusedSuccessfully = this . _focusTrap ?. focusInitialElement ( ) ;
289
+ // If we weren't able to find a focusable element in the dialog, then focus the dialog
290
+ // container instead.
291
+ if ( ! focusedSuccessfully ) {
292
+ this . _focusDialogContainer ( ) ;
293
+ }
294
+ } ,
295
+ { injector : this . _injector } ,
296
+ ) ;
293
297
break ;
294
298
case 'first-heading' :
295
299
afterNextRender (
Original file line number Diff line number Diff line change @@ -725,7 +725,6 @@ describe('MatBottomSheet', () => {
725
725
726
726
const bottomSheetRef = bottomSheet . open ( PizzaMsg , { viewContainerRef : testViewContainerRef } ) ;
727
727
728
- flush ( ) ;
729
728
viewContainerFixture . detectChanges ( ) ;
730
729
flush ( ) ;
731
730
viewContainerFixture . detectChanges ( ) ;
@@ -763,7 +762,6 @@ describe('MatBottomSheet', () => {
763
762
restoreFocus : false ,
764
763
} ) ;
765
764
766
- flush ( ) ;
767
765
viewContainerFixture . detectChanges ( ) ;
768
766
flush ( ) ;
769
767
viewContainerFixture . detectChanges ( ) ;
@@ -804,7 +802,6 @@ describe('MatBottomSheet', () => {
804
802
805
803
const bottomSheetRef = bottomSheet . open ( PizzaMsg , { viewContainerRef : testViewContainerRef } ) ;
806
804
807
- flush ( ) ;
808
805
viewContainerFixture . detectChanges ( ) ;
809
806
flush ( ) ;
810
807
viewContainerFixture . detectChanges ( ) ;
@@ -822,9 +819,9 @@ describe('MatBottomSheet', () => {
822
819
. withContext ( 'Expected focus to be on the alternate button.' )
823
820
. toBe ( 'other-button' ) ;
824
821
825
- flushMicrotasks ( ) ;
826
822
viewContainerFixture . detectChanges ( ) ;
827
823
flush ( ) ;
824
+ viewContainerFixture . detectChanges ( ) ;
828
825
829
826
expect ( document . activeElement ! . id )
830
827
. withContext ( 'Expected focus to stay on the alternate button.' )
You can’t perform that action at this time.
0 commit comments