Skip to content

Commit 8dcaacd

Browse files
committed
refactor(material/sidenav): Remove use of focusInitialElementWhenReady
1 parent cfdfa9a commit 8dcaacd

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/material/sidenav/drawer.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@ export class MatDrawer implements AfterViewInit, AfterContentChecked, OnDestroy
332332
if (this._doc) {
333333
this._elementFocusedBeforeDrawerWasOpened = this._doc.activeElement as HTMLElement;
334334
}
335-
336335
this._takeFocus();
337336
} else if (this._isFocusWithinDrawer()) {
338337
this._restoreFocus(this._openedVia || 'program');
@@ -437,11 +436,10 @@ export class MatDrawer implements AfterViewInit, AfterContentChecked, OnDestroy
437436
return;
438437
case true:
439438
case 'first-tabbable':
440-
this._focusTrap.focusInitialElementWhenReady().then(hasMovedFocus => {
441-
if (!hasMovedFocus && typeof this._elementRef.nativeElement.focus === 'function') {
442-
element.focus();
443-
}
444-
});
439+
const hasMovedFocus = this._focusTrap.focusInitialElement();
440+
if (!hasMovedFocus && typeof element.focus === 'function') {
441+
element.focus();
442+
}
445443
break;
446444
case 'first-heading':
447445
this._focusByCssSelector('h1, h2, h3, h4, h5, h6, [role="heading"]');

0 commit comments

Comments
 (0)