diff --git a/src/cdk/dialog/dialog-container.ts b/src/cdk/dialog/dialog-container.ts index aeb1c9a742ba..ab77ef8e9554 100644 --- a/src/cdk/dialog/dialog-container.ts +++ b/src/cdk/dialog/dialog-container.ts @@ -283,13 +283,17 @@ export class CdkDialogContainer break; case true: case 'first-tabbable': - this._focusTrap?.focusInitialElementWhenReady().then(focusedSuccessfully => { - // If we weren't able to find a focusable element in the dialog, then focus the dialog - // container instead. - if (!focusedSuccessfully) { - this._focusDialogContainer(); - } - }); + afterNextRender( + () => { + const focusedSuccessfully = this._focusTrap?.focusInitialElement(); + // If we weren't able to find a focusable element in the dialog, then focus the dialog + // container instead. + if (!focusedSuccessfully) { + this._focusDialogContainer(); + } + }, + {injector: this._injector}, + ); break; case 'first-heading': afterNextRender(