Skip to content

Commit

Permalink
revert(5422): chore(dialog): switch to OnPush change detection (#6123)
Browse files Browse the repository at this point in the history
* fix(sidenav): animate sidenav on open/close changes

* Revert "chore(dialog): switch to OnPush change detection (#5422)"

This reverts commit cf071c7.
  • Loading branch information
andrewseguin authored Jul 28, 2017
1 parent cf071c7 commit 11975e6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 23 deletions.
18 changes: 2 additions & 16 deletions src/lib/dialog/dialog-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import {
EventEmitter,
Inject,
Optional,
ChangeDetectionStrategy,
ChangeDetectorRef,
} from '@angular/core';
import {
animate,
Expand Down Expand Up @@ -51,7 +49,6 @@ export function throwMdDialogContentAlreadyAttachedError() {
selector: 'md-dialog-container, mat-dialog-container',
templateUrl: 'dialog-container.html',
styleUrls: ['dialog.css'],
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
animations: [
trigger('slideDialog', [
Expand Down Expand Up @@ -107,7 +104,6 @@ export class MdDialogContainer extends BasePortalHost {
private _ngZone: NgZone,
private _elementRef: ElementRef,
private _focusTrapFactory: FocusTrapFactory,
private _changeDetectorRef: ChangeDetectorRef,
@Optional() @Inject(DOCUMENT) _document: any) {

super();
Expand All @@ -124,12 +120,7 @@ export class MdDialogContainer extends BasePortalHost {
}

this._savePreviouslyFocusedElement();
const componentRef = this._portalHost.attachComponentPortal(portal);

// Ensure that the initial view change are picked up.
componentRef.changeDetectorRef.markForCheck();

return componentRef;
return this._portalHost.attachComponentPortal(portal);
}

/**
Expand All @@ -142,12 +133,7 @@ export class MdDialogContainer extends BasePortalHost {
}

this._savePreviouslyFocusedElement();
const locals = this._portalHost.attachTemplatePortal(portal);

// Ensure that the initial view change are picked up.
this._changeDetectorRef.markForCheck();

return locals;
return this._portalHost.attachTemplatePortal(portal);
}

/** Moves the focus inside the focus trap. */
Expand Down
10 changes: 3 additions & 7 deletions src/lib/sidenav/sidenav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,13 +379,6 @@ export class MdSidenavContainer implements AfterContentInit {
this._watchSidenavAlign(sidenav);
});
this._validateDrawers();

// Give the view a chance to render the initial state, then enable transitions. Note that we
// don't use data binding, because we're not guaranteed that newer version of Angular will
// re-evaluate them after we set the flag here.
first.call(this._ngZone.onMicrotaskEmpty).subscribe(() => {
this._renderer.addClass(this._element.nativeElement, 'mat-sidenav-transition');
});
}

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

Expand Down

0 comments on commit 11975e6

Please sign in to comment.