Skip to content
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

fix: do not update form-layout when it is not visible (#7792) (CP: 24.4) #7794

Merged
merged 1 commit into from
Sep 11, 2024
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
1 change: 1 addition & 0 deletions packages/form-layout/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
],
"dependencies": {
"@polymer/polymer": "^3.0.0",
"@vaadin/a11y-base": "~24.4.8",
"@vaadin/component-base": "~24.4.8",
"@vaadin/vaadin-lumo-styles": "~24.4.8",
"@vaadin/vaadin-material-styles": "~24.4.8",
Expand Down
6 changes: 6 additions & 0 deletions packages/form-layout/src/vaadin-form-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
*/
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
import { isElementHidden } from '@vaadin/a11y-base/src/focus-utils.js';
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
import { ResizeMixin } from '@vaadin/component-base/src/resize-mixin.js';
Expand Down Expand Up @@ -456,6 +457,11 @@ class FormLayout extends ResizeMixin(ElementMixin(ThemableMixin(PolymerElement))
* @protected
*/
_updateLayout() {
// Do not update layout when invisible
if (isElementHidden(this)) {
return;
}

/*
The item width formula:

Expand Down
9 changes: 9 additions & 0 deletions packages/form-layout/test/form-layout.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -627,5 +627,14 @@ describe('form layout', () => {
await nextRender(container);
expect(getComputedStyle(itemsList[1]).marginLeft).to.be.equal('0px');
});

it('should not update layout when setting hidden to true', async () => {
const percent = getParsedWidth(layout.firstElementChild).percentage;

container.hidden = true;
await nextRender();

expect(getParsedWidth(layout.firstElementChild).percentage).to.be.equal(percent);
});
});
});
Loading