From e95623d0c14924cfa439c2044ac36745af4db53a Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Tue, 12 Jun 2018 18:50:06 +0200 Subject: [PATCH] fix(dialog): inconsistently resetting dimensions (#11723) Currently when no dialog dimensions are set, no CSS properties will be passed on to the overlay panel, however if the dialog dimensions are reset via the `DialogRef`, the overlay's `width` and `height` will be set explicitly to `auto`. This is inconsistent and could break some edge cases. --- src/lib/dialog/dialog-ref.ts | 2 +- src/lib/dialog/dialog.spec.ts | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/lib/dialog/dialog-ref.ts b/src/lib/dialog/dialog-ref.ts index 280a7928b22..10b855e9d50 100644 --- a/src/lib/dialog/dialog-ref.ts +++ b/src/lib/dialog/dialog-ref.ts @@ -181,7 +181,7 @@ export class MatDialogRef { * @param width New width of the dialog. * @param height New height of the dialog. */ - updateSize(width: string = 'auto', height: string = 'auto'): this { + updateSize(width: string = '', height: string = ''): this { this._getPositionStrategy().width(width).height(height); this._overlayRef.updatePosition(); return this; diff --git a/src/lib/dialog/dialog.spec.ts b/src/lib/dialog/dialog.spec.ts index 4a4aabb52c2..d1edf75cccb 100644 --- a/src/lib/dialog/dialog.spec.ts +++ b/src/lib/dialog/dialog.spec.ts @@ -537,6 +537,27 @@ describe('MatDialog', () => { expect(overlayPane.style.width).toBe('200px'); }); + it('should reset the overlay dimensions to their initial size', () => { + let dialogRef = dialog.open(PizzaMsg); + + viewContainerFixture.detectChanges(); + + let overlayPane = overlayContainerElement.querySelector('.cdk-overlay-pane') as HTMLElement; + + expect(overlayPane.style.width).toBeFalsy(); + expect(overlayPane.style.height).toBeFalsy(); + + dialogRef.updateSize('200px', '200px'); + + expect(overlayPane.style.width).toBe('200px'); + expect(overlayPane.style.height).toBe('200px'); + + dialogRef.updateSize(); + + expect(overlayPane.style.width).toBeFalsy(); + expect(overlayPane.style.height).toBeFalsy(); + }); + it('should allow setting the layout direction', () => { dialog.open(PizzaMsg, { direction: 'rtl' });