FIO-9974 fixed Clear on Hide for layout components #6112
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 tofalse
. 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 theclearOnHide
property can be manually overwritten totrue
using the Layout component's JSON schema. Several issues related to this functionality have been found and fixed:clearOnHide
property was set totrue
. This means that when hiding the FieldSet component, all the values of the child components were always cleared, regardless of whetherclearOnHide
property was set in the JSON schema or not, contrary to the documentation. This was fixed by addingclearOnHide
property asfalse
for the FieldSet component a default value.clearOnHide
property astrue
did not change the behavior of the Layout components. That is, even if the User manually set theclearOnHide
property totrue
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 thedeleteValue
method, the values of child components were ignored and not cleared, even when settingclearOnHide
astrue
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: