Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert(5422): chore(dialog): switch to OnPush change detection #6123

Merged
merged 2 commits into from
Jul 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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