Skip to content

fix: allow setting null explicitly to reset width and height (#9456) (CP: 24.8) #9458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/dialog/src/vaadin-dialog-overlay-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ export const DialogOverlayMixin = (superClass) =>
}

Object.keys(parsedBounds).forEach((arg) => {
if (!isNaN(parsedBounds[arg])) {
// Allow setting width or height to `null`
if (parsedBounds[arg] !== null && !isNaN(parsedBounds[arg])) {
parsedBounds[arg] = `${parsedBounds[arg]}px`;
}
});
Expand Down
30 changes: 30 additions & 0 deletions packages/dialog/test/dialog.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,5 +342,35 @@ describe('vaadin-dialog', () => {
expect(getComputedStyle(overlay.$.overlay).position).to.equal('relative');
expect(getComputedStyle(overlay.$.overlay).maxWidth).to.equal('100%');
});

it('should reset overlay width when set to null', async () => {
dialog.opened = true;
await nextRender();

const originalWidth = getComputedStyle(overlay.$.overlay).width;

dialog.width = 300;
await nextRender();

dialog.width = null;
await nextRender();

expect(getComputedStyle(overlay.$.overlay).width).to.equal(originalWidth);
});

it('should reset overlay height when set to null', async () => {
dialog.opened = true;
await nextRender();

const originalHeight = getComputedStyle(overlay.$.overlay).height;

dialog.height = 400;
await nextRender();

dialog.height = null;
await nextRender();

expect(getComputedStyle(overlay.$.overlay).height).to.equal(originalHeight);
});
});
});