Skip to content

Commit

Permalink
Merge pull request #786 from open-formulieren/bug/4699-dont-render-hi…
Browse files Browse the repository at this point in the history
…dden-components

Don't render AddressNL component when it hidden
  • Loading branch information
sergei-maertens authored Jan 28, 2025
2 parents 45f6c4e + bf05e4a commit 82df116
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/formio/components/AddressNL.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,16 @@ export default class AddressNL extends Field {
addressNLContainer: 'single',
});
return super.attach(element).then(() => {
this.reactRoot = createRoot(this.refs.addressNLContainer);
this.renderReact();
if (!this.component?.hidden) {
this.reactRoot = createRoot(this.refs.addressNLContainer);
this.renderReact();
}
});
}

destroy() {
const container = this.refs.addressNLContainer;
if (container) this.reactRoot.unmount();
if (!this.component?.hidden && container) this.reactRoot.unmount();
super.destroy();
}

Expand Down Expand Up @@ -146,6 +148,9 @@ export default class AddressNL extends Field {
}

renderReact() {
if (this.component?.hidden) {
return;
}
const required = this.component?.validate?.required || false;
const initialValues = {...AddressNL.emptyValue, ...this.dataValue};

Expand Down

0 comments on commit 82df116

Please sign in to comment.