Skip to content

Commit fa06ff3

Browse files
committed
refactor(sidenav): constructor breaking changes for 8.0
Handles the breaking constructor changes for 8.0 in `material/sidenav`. BREAKING CHANGES: * `viewportRuler` parameter in `MatDrawerContainer` constructor is now required. Also the parameter order has changed as a result.
1 parent bb5d544 commit fa06ff3

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

src/lib/schematics/ng-update/data/constructor-checks.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ export const constructorChecks: VersionChanges<ConstructorChecksUpgradeData> = {
1818
{
1919
pr: 'https://github.com/angular/material2/pull/15647',
2020
changes: ['MatFormField', 'MatTabLink', 'MatVerticalStepper']
21+
},
22+
{
23+
pr: 'https://github.com/angular/material2/pull/15770',
24+
changes: ['MatDrawerContainer']
2125
}
2226
],
2327

src/lib/sidenav/drawer.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -508,13 +508,9 @@ export class MatDrawerContainer implements AfterContentInit, DoCheck, OnDestroy
508508
private _element: ElementRef<HTMLElement>,
509509
private _ngZone: NgZone,
510510
private _changeDetectorRef: ChangeDetectorRef,
511+
viewportRuler: ViewportRuler,
511512
@Inject(MAT_DRAWER_DEFAULT_AUTOSIZE) defaultAutosize = false,
512-
@Optional() @Inject(ANIMATION_MODULE_TYPE) private _animationMode?: string,
513-
/**
514-
* @deprecated viewportRuler to become a required parameter.
515-
* @breaking-change 8.0.0
516-
*/
517-
@Optional() viewportRuler?: ViewportRuler) {
513+
@Optional() @Inject(ANIMATION_MODULE_TYPE) private _animationMode?: string) {
518514

519515
// If a `Dir` directive exists up the tree, listen direction changes
520516
// and update the left/right properties to point to the proper start/end.
@@ -527,11 +523,9 @@ export class MatDrawerContainer implements AfterContentInit, DoCheck, OnDestroy
527523

528524
// Since the minimum width of the sidenav depends on the viewport width,
529525
// we need to recompute the margins if the viewport changes.
530-
if (viewportRuler) {
531-
viewportRuler.change()
532-
.pipe(takeUntil(this._destroyed))
533-
.subscribe(() => this._updateContentMargins());
534-
}
526+
viewportRuler.change()
527+
.pipe(takeUntil(this._destroyed))
528+
.subscribe(() => this._updateContentMargins());
535529

536530
this._autosize = defaultAutosize;
537531
}

tools/public_api_guard/lib/sidenav.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ export declare class MatDrawerContainer implements AfterContentInit, DoCheck, On
5252
hasBackdrop: any;
5353
readonly scrollable: CdkScrollable;
5454
readonly start: MatDrawer | null;
55-
constructor(_dir: Directionality, _element: ElementRef<HTMLElement>, _ngZone: NgZone, _changeDetectorRef: ChangeDetectorRef, defaultAutosize?: boolean, _animationMode?: string | undefined,
56-
viewportRuler?: ViewportRuler);
55+
constructor(_dir: Directionality, _element: ElementRef<HTMLElement>, _ngZone: NgZone, _changeDetectorRef: ChangeDetectorRef, viewportRuler: ViewportRuler, defaultAutosize?: boolean, _animationMode?: string | undefined);
5756
_closeModalDrawer(): void;
5857
_isShowingBackdrop(): boolean;
5958
_onBackdropClicked(): void;

0 commit comments

Comments
 (0)