FIO-9974 fixed Clear on Hide for layout components
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
clearOnHideproperty was set totrue. This means that when hiding the FieldSet component, all the values of the child components were always cleared, regardless of whetherclearOnHideproperty was set in the JSON schema or not, contrary to the documentation. This was fixed by addingclearOnHideproperty asfalsefor the FieldSet component a default value. - Manually overwriting the value of the
clearOnHideproperty astruedid not change the behavior of the Layout components. That is, even if the User manually set theclearOnHideproperty totruein 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 thedeleteValuemethod, the values of child components were ignored and not cleared, even when settingclearOnHideastruein 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
The approach was changed and now the parent layout-component check is used instead of the eachComponent method.
@travist can you review the latest changes to this pr