Skip to content

Commit e95623d

Browse files
crisbetojelbourn
authored andcommitted
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.
1 parent 0a39595 commit e95623d

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/lib/dialog/dialog-ref.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export class MatDialogRef<T, R = any> {
181181
* @param width New width of the dialog.
182182
* @param height New height of the dialog.
183183
*/
184-
updateSize(width: string = 'auto', height: string = 'auto'): this {
184+
updateSize(width: string = '', height: string = ''): this {
185185
this._getPositionStrategy().width(width).height(height);
186186
this._overlayRef.updatePosition();
187187
return this;

src/lib/dialog/dialog.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,27 @@ describe('MatDialog', () => {
537537
expect(overlayPane.style.width).toBe('200px');
538538
});
539539

540+
it('should reset the overlay dimensions to their initial size', () => {
541+
let dialogRef = dialog.open(PizzaMsg);
542+
543+
viewContainerFixture.detectChanges();
544+
545+
let overlayPane = overlayContainerElement.querySelector('.cdk-overlay-pane') as HTMLElement;
546+
547+
expect(overlayPane.style.width).toBeFalsy();
548+
expect(overlayPane.style.height).toBeFalsy();
549+
550+
dialogRef.updateSize('200px', '200px');
551+
552+
expect(overlayPane.style.width).toBe('200px');
553+
expect(overlayPane.style.height).toBe('200px');
554+
555+
dialogRef.updateSize();
556+
557+
expect(overlayPane.style.width).toBeFalsy();
558+
expect(overlayPane.style.height).toBeFalsy();
559+
});
560+
540561
it('should allow setting the layout direction', () => {
541562
dialog.open(PizzaMsg, { direction: 'rtl' });
542563

0 commit comments

Comments
 (0)