formio.js icon indicating copy to clipboard operation
formio.js copied to clipboard

FIO-9974 fixed Clear on Hide for layout components

Open HannaKurban opened this issue 7 months ago • 2 comments

Link to Jira Ticket

https://formio.atlassian.net/browse/FIO-9974

Description

According to the documentation, for Layout components, such as Panels, Well, Fieldset, etc the default value of clearOnHide is set to false. That is, when hiding the parent Layout component , the value of the child components should not be cleared (see Example Scenarios 3). But the value of the clearOnHide property can be manually overwritten to true using the Layout component's JSON schema. Several issues related to this functionality have been found and fixed:

  • For the FieldSet component, the default value of clearOnHide property was set to true. This means that when hiding the FieldSet component, all the values of the child components were always cleared, regardless of whether clearOnHide property was set in the JSON schema or not, contrary to the documentation. This was fixed by adding clearOnHide property as false for the FieldSet component a default value.
  • Manually overwriting the value of the clearOnHide property as true did not change the behavior of the Layout components. That is, even if the User manually set the clearOnHide property to true in the Layout component's JSON schema, the values of the child components were not cleared, contrary to the documentation. This was due to the fact that Layout components, such as Panels, Well, Fieldset, etc do not have their own values, therefore, in the deleteValue method, the values of child components were ignored and not cleared, even when setting clearOnHide as true in the JSON schema of the Layout component . This was fixed by adding a check for Layout components and clearOnHide property.

Breaking Changes / Backwards Compatibility

n/a

Dependencies

n/a

How has this PR been tested?

Added automatic tests covering the behavior of the clearOnHide functionality for the Layout component for both cases: default behavior and manual overwriting of the clearOnHide property as true. All tests pass locally

Checklist:

  • [x] I have completed the above PR template
  • [ ] I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation (if applicable)
  • [x] My changes generate no new warnings
  • [x] My changes include tests that prove my fix is effective (or that my feature works as intended)
  • [x] New and existing unit/integration tests pass locally with my changes
  • [ ] Any dependent changes have corresponding PRs that are listed above

HannaKurban avatar Apr 30 '25 11:04 HannaKurban

The approach was changed and now the parent layout-component check is used instead of the eachComponent method.

HannaKurban avatar Aug 29 '25 13:08 HannaKurban

@travist can you review the latest changes to this pr

johnformio avatar Sep 08 '25 22:09 johnformio