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.
This commit is contained in:
Kristiyan Kostadinov
2018-06-12 18:50:06 +02:00
committed by Jeremy Elbourn
parent 0a39595e7a
commit e95623d0c1
2 changed files with 22 additions and 1 deletions
+1 -1
View File
@@ -181,7 +181,7 @@ export class MatDialogRef<T, R = any> {
* @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;
+21
View File
@@ -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' });