diff --git a/src/cdk/overlay/overlay-directives.ts b/src/cdk/overlay/overlay-directives.ts index 0cb124b9ae7e..99b30b4d345a 100644 --- a/src/cdk/overlay/overlay-directives.ts +++ b/src/cdk/overlay/overlay-directives.ts @@ -339,7 +339,7 @@ export class CdkConnectedOverlay implements OnDestroy, OnChanges { } this._position.withDirection(this.dir); - this._overlayRef.setDirection(this.dir); + this._overlayRef.getConfig().direction = this.dir; this._document.addEventListener('keydown', this._escapeListener); if (!this._overlayRef.hasAttached()) { diff --git a/src/cdk/overlay/overlay-ref.ts b/src/cdk/overlay/overlay-ref.ts index c1be7f8b78b2..22d2474e43d5 100644 --- a/src/cdk/overlay/overlay-ref.ts +++ b/src/cdk/overlay/overlay-ref.ts @@ -6,9 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import {Direction} from '@angular/cdk/bidi'; -import {ComponentPortal, Portal, PortalOutlet, TemplatePortal} from '@angular/cdk/portal'; -import {ComponentRef, EmbeddedViewRef, NgZone} from '@angular/core'; +import {Portal, PortalOutlet} from '@angular/cdk/portal'; +import {NgZone} from '@angular/core'; import {Observable} from 'rxjs/Observable'; import {take} from 'rxjs/operators/take'; import {Subject} from 'rxjs/Subject'; @@ -16,11 +15,6 @@ import {OverlayKeyboardDispatcher} from './keyboard/overlay-keyboard-dispatcher' import {OverlayConfig} from './overlay-config'; -/** An object where all of its properties cannot be written. */ -export type ImmutableObject = { - readonly [P in keyof T]: T[P]; -}; - /** * Reference to an overlay that has been created with the Overlay service. * Used to manipulate or dispose of said overlay. @@ -37,7 +31,7 @@ export class OverlayRef implements PortalOutlet { constructor( private _portalOutlet: PortalOutlet, private _pane: HTMLElement, - private _config: ImmutableObject, + private _config: OverlayConfig, private _ngZone: NgZone, private _keyboardDispatcher: OverlayKeyboardDispatcher) { @@ -51,10 +45,6 @@ export class OverlayRef implements PortalOutlet { return this._pane; } - attach(portal: ComponentPortal): ComponentRef; - attach(portal: TemplatePortal): EmbeddedViewRef; - attach(portal: any): any; - /** * Attaches content, given via a Portal, to the overlay. * If the overlay is configured to have a backdrop, it will be created. @@ -71,8 +61,8 @@ export class OverlayRef implements PortalOutlet { // Update the pane element with the given configuration. this._updateStackingOrder(); - this._updateElementSize(); - this._updateElementDirection(); + this.updateSize(); + this.updateDirection(); if (this._config.scrollStrategy) { this._config.scrollStrategy.enable(); @@ -208,25 +198,13 @@ export class OverlayRef implements PortalOutlet { } } - /** Update the size properties of the overlay. */ - updateSize(sizeConfig: OverlaySizeConfig) { - this._config = {...this._config, ...sizeConfig}; - this._updateElementSize(); - } - - /** Sets the LTR/RTL direction for the overlay. */ - setDirection(dir: Direction) { - this._config = {...this._config, direction: dir}; - this._updateElementDirection(); - } - /** Updates the text direction of the overlay panel. */ - private _updateElementDirection() { + private updateDirection() { this._pane.setAttribute('dir', this._config.direction!); } - /** Updates the size of the overlay element based on the overlay config. */ - private _updateElementSize() { + /** Updates the size of the overlay based on the overlay config. */ + updateSize() { if (this._config.width || this._config.width === 0) { this._pane.style.width = formatCssUnit(this._config.width); } @@ -275,12 +253,10 @@ export class OverlayRef implements PortalOutlet { this._backdropElement.addEventListener('click', () => this._backdropClick.next(null)); // Add class to fade-in the backdrop after one frame. - this._ngZone.runOutsideAngular(() => { - requestAnimationFrame(() => { - if (this._backdropElement) { - this._backdropElement.classList.add('cdk-overlay-backdrop-showing'); - } - }); + requestAnimationFrame(() => { + if (this._backdropElement) { + this._backdropElement.classList.add('cdk-overlay-backdrop-showing'); + } }); } @@ -341,14 +317,3 @@ export class OverlayRef implements PortalOutlet { function formatCssUnit(value: number | string) { return typeof value === 'string' ? value as string : `${value}px`; } - - -/** Size properties for an overlay. */ -export interface OverlaySizeConfig { - width?: number | string; - height?: number | string; - minWidth?: number | string; - minHeight?: number | string; - maxWidth?: number | string; - maxHeight?: number | string; -} diff --git a/src/cdk/portal/portal.ts b/src/cdk/portal/portal.ts index 981f12f562e1..911d01a6484c 100644 --- a/src/cdk/portal/portal.ts +++ b/src/cdk/portal/portal.ts @@ -181,10 +181,6 @@ export abstract class BasePortalOutlet implements PortalOutlet { return !!this._attachedPortal; } - attach(portal: ComponentPortal): ComponentRef; - attach(portal: TemplatePortal): EmbeddedViewRef; - attach(portal: any): any; - /** Attaches a portal. */ attach(portal: Portal): any { if (!portal) { diff --git a/src/lib/autocomplete/autocomplete-trigger.ts b/src/lib/autocomplete/autocomplete-trigger.ts index 1e328390e6be..9abc6c95fafc 100644 --- a/src/lib/autocomplete/autocomplete-trigger.ts +++ b/src/lib/autocomplete/autocomplete-trigger.ts @@ -458,7 +458,8 @@ export class MatAutocompleteTrigger implements ControlValueAccessor, OnDestroy { this._overlayRef = this._overlay.create(this._getOverlayConfig()); } else { /** Update the panel width, in case the host width has changed */ - this._overlayRef.updateSize({width: this._getHostWidth()}); + this._overlayRef.getConfig().width = this._getHostWidth(); + this._overlayRef.updateSize(); } if (this._overlayRef && !this._overlayRef.hasAttached()) {