Skip to content

Commit 9f3a8bf

Browse files
fix: allow setting null explicitly to reset width and height (#9456) (#9458)
Co-authored-by: Serhii Kulykov <[email protected]>
1 parent 901d3eb commit 9f3a8bf

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

packages/dialog/src/vaadin-dialog-overlay-mixin.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ export const DialogOverlayMixin = (superClass) =>
207207
}
208208

209209
Object.keys(parsedBounds).forEach((arg) => {
210-
if (!isNaN(parsedBounds[arg])) {
210+
// Allow setting width or height to `null`
211+
if (parsedBounds[arg] !== null && !isNaN(parsedBounds[arg])) {
211212
parsedBounds[arg] = `${parsedBounds[arg]}px`;
212213
}
213214
});

packages/dialog/test/dialog.test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,5 +342,35 @@ describe('vaadin-dialog', () => {
342342
expect(getComputedStyle(overlay.$.overlay).position).to.equal('relative');
343343
expect(getComputedStyle(overlay.$.overlay).maxWidth).to.equal('100%');
344344
});
345+
346+
it('should reset overlay width when set to null', async () => {
347+
dialog.opened = true;
348+
await nextRender();
349+
350+
const originalWidth = getComputedStyle(overlay.$.overlay).width;
351+
352+
dialog.width = 300;
353+
await nextRender();
354+
355+
dialog.width = null;
356+
await nextRender();
357+
358+
expect(getComputedStyle(overlay.$.overlay).width).to.equal(originalWidth);
359+
});
360+
361+
it('should reset overlay height when set to null', async () => {
362+
dialog.opened = true;
363+
await nextRender();
364+
365+
const originalHeight = getComputedStyle(overlay.$.overlay).height;
366+
367+
dialog.height = 400;
368+
await nextRender();
369+
370+
dialog.height = null;
371+
await nextRender();
372+
373+
expect(getComputedStyle(overlay.$.overlay).height).to.equal(originalHeight);
374+
});
345375
});
346376
});

0 commit comments

Comments
 (0)