Skip to content

Commit 6dd1689

Browse files
committedJun 10, 2024·
fix(material/dialog): Make focus behavior consistent across zoneful/zoneless apps (#29192)
(cherry picked from commit 3b32d0e)
1 parent 8dbd669 commit 6dd1689

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed
 

‎src/cdk/dialog/dialog-container.ts

+11-7
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,17 @@ export class CdkDialogContainer<C extends DialogConfig = DialogConfig>
283283
break;
284284
case true:
285285
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+
);
293297
break;
294298
case 'first-heading':
295299
afterNextRender(

0 commit comments

Comments
 (0)
Please sign in to comment.