Skip to content

Commit 11975e6

Browse files
authored
revert(5422): chore(dialog): switch to OnPush change detection (#6123)
* fix(sidenav): animate sidenav on open/close changes * Revert "chore(dialog): switch to OnPush change detection (#5422)" This reverts commit cf071c7.
1 parent cf071c7 commit 11975e6

File tree

2 files changed

+5
-23
lines changed

2 files changed

+5
-23
lines changed

src/lib/dialog/dialog-container.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ import {
1616
EventEmitter,
1717
Inject,
1818
Optional,
19-
ChangeDetectionStrategy,
20-
ChangeDetectorRef,
2119
} from '@angular/core';
2220
import {
2321
animate,
@@ -51,7 +49,6 @@ export function throwMdDialogContentAlreadyAttachedError() {
5149
selector: 'md-dialog-container, mat-dialog-container',
5250
templateUrl: 'dialog-container.html',
5351
styleUrls: ['dialog.css'],
54-
changeDetection: ChangeDetectionStrategy.OnPush,
5552
encapsulation: ViewEncapsulation.None,
5653
animations: [
5754
trigger('slideDialog', [
@@ -107,7 +104,6 @@ export class MdDialogContainer extends BasePortalHost {
107104
private _ngZone: NgZone,
108105
private _elementRef: ElementRef,
109106
private _focusTrapFactory: FocusTrapFactory,
110-
private _changeDetectorRef: ChangeDetectorRef,
111107
@Optional() @Inject(DOCUMENT) _document: any) {
112108

113109
super();
@@ -124,12 +120,7 @@ export class MdDialogContainer extends BasePortalHost {
124120
}
125121

126122
this._savePreviouslyFocusedElement();
127-
const componentRef = this._portalHost.attachComponentPortal(portal);
128-
129-
// Ensure that the initial view change are picked up.
130-
componentRef.changeDetectorRef.markForCheck();
131-
132-
return componentRef;
123+
return this._portalHost.attachComponentPortal(portal);
133124
}
134125

135126
/**
@@ -142,12 +133,7 @@ export class MdDialogContainer extends BasePortalHost {
142133
}
143134

144135
this._savePreviouslyFocusedElement();
145-
const locals = this._portalHost.attachTemplatePortal(portal);
146-
147-
// Ensure that the initial view change are picked up.
148-
this._changeDetectorRef.markForCheck();
149-
150-
return locals;
136+
return this._portalHost.attachTemplatePortal(portal);
151137
}
152138

153139
/** Moves the focus inside the focus trap. */

src/lib/sidenav/sidenav.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -379,13 +379,6 @@ export class MdSidenavContainer implements AfterContentInit {
379379
this._watchSidenavAlign(sidenav);
380380
});
381381
this._validateDrawers();
382-
383-
// Give the view a chance to render the initial state, then enable transitions. Note that we
384-
// don't use data binding, because we're not guaranteed that newer version of Angular will
385-
// re-evaluate them after we set the flag here.
386-
first.call(this._ngZone.onMicrotaskEmpty).subscribe(() => {
387-
this._renderer.addClass(this._element.nativeElement, 'mat-sidenav-transition');
388-
});
389382
}
390383

391384
/** Calls `open` of both start and end sidenavs */
@@ -409,6 +402,9 @@ export class MdSidenavContainer implements AfterContentInit {
409402
*/
410403
private _watchSidenavToggle(sidenav: MdSidenav): void {
411404
merge(sidenav.onOpenStart, sidenav.onCloseStart).subscribe(() => {
405+
// Set the transition class on the container so that the animations occur. This should not
406+
// be set initially because animations should only be triggered via a change in state.
407+
this._renderer.addClass(this._element.nativeElement, 'mat-sidenav-transition');
412408
this._changeDetectorRef.markForCheck();
413409
});
414410

0 commit comments

Comments
 (0)