Skip to content
Merged
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: 16 additions & 2 deletions src/lib/dialog/dialog-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
EventEmitter,
Inject,
Optional,
ChangeDetectionStrategy,
ChangeDetectorRef,
} from '@angular/core';
import {
animate,
Expand Down Expand Up @@ -50,6 +52,7 @@ 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 @@ -100,6 +103,7 @@ 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 @@ -116,7 +120,12 @@ export class MdDialogContainer extends BasePortalHost {
}

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

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

return componentRef;
}

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

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

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

return locals;
}

/** Moves the focus inside the focus trap. */
Expand Down