mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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 cf071c75f5.
This commit is contained in:
@@ -16,8 +16,6 @@ import {
|
||||
EventEmitter,
|
||||
Inject,
|
||||
Optional,
|
||||
ChangeDetectionStrategy,
|
||||
ChangeDetectorRef,
|
||||
} from '@angular/core';
|
||||
import {
|
||||
animate,
|
||||
@@ -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', [
|
||||
@@ -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();
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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. */
|
||||
|
||||
@@ -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 */
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user