Skip to content

Commit 66741b8

Browse files
authored
fix(material/sidenav): remove deprecated API usage (#30268)
The sidenav was using `AfterRenderPhase` which is deprecated. These changes switch it to the supported API.
1 parent 980f9ba commit 66741b8

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

src/material/sidenav/drawer.ts

+7-18
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {DOCUMENT} from '@angular/common';
2121
import {
2222
AfterContentInit,
2323
afterNextRender,
24-
AfterRenderPhase,
2524
AfterViewInit,
2625
ANIMATION_MODULE_TYPE,
2726
ChangeDetectionStrategy,
@@ -966,31 +965,21 @@ export class MatDrawerContainer implements AfterContentInit, DoCheck, OnDestroy
966965
* re-validate drawers when the position changes.
967966
*/
968967
private _watchDrawerPosition(drawer: MatDrawer): void {
969-
if (!drawer) {
970-
return;
971-
}
972968
// NOTE: We need to wait for the microtask queue to be empty before validating,
973969
// since both drawers may be swapping positions at the same time.
974970
drawer.onPositionChanged.pipe(takeUntil(this._drawers.changes)).subscribe(() => {
975-
afterNextRender(
976-
() => {
977-
this._validateDrawers();
978-
},
979-
{injector: this._injector, phase: AfterRenderPhase.Read},
980-
);
971+
afterNextRender({read: () => this._validateDrawers()}, {injector: this._injector});
981972
});
982973
}
983974

984975
/** Subscribes to changes in drawer mode so we can run change detection. */
985976
private _watchDrawerMode(drawer: MatDrawer): void {
986-
if (drawer) {
987-
drawer._modeChanged
988-
.pipe(takeUntil(merge(this._drawers.changes, this._destroyed)))
989-
.subscribe(() => {
990-
this.updateContentMargins();
991-
this._changeDetectorRef.markForCheck();
992-
});
993-
}
977+
drawer._modeChanged
978+
.pipe(takeUntil(merge(this._drawers.changes, this._destroyed)))
979+
.subscribe(() => {
980+
this.updateContentMargins();
981+
this._changeDetectorRef.markForCheck();
982+
});
994983
}
995984

996985
/** Toggles the 'mat-drawer-opened' class on the main 'mat-drawer-container' element. */

0 commit comments

Comments
 (0)