FIO-9002: fix issue with conditionally hidden duplicate nested form paths #162
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-9002
Description
Imagine a parent form which nests two forms - conditionally shown on a parent checkbox - which, in turn, nest the same resource, something like:
Normally, we'd expect component pathing to come to our rescue here, i.e. conditionally hidden components would be keyed by absolute path and hidden/cleared/what-have-you'd as expected. However, there is a wrinkle: since we "mask" the paths and data of nested forms in order to ensure that their evaluation context is correct, the pathing for hidden components and nested forms becomes unusable, as one nested form's hidden components will be keyed in the "conditionals" scope identically to another, which means they'll all be hidden/cleared/what-have-you'd. So how do you ensure a child knows its parent is hidden without resorting to pathing?
This PR introduces the concept of "ephermal state," or state that is added as a non-enumerable property to the component JSON in order to facilitate stateful operations during form and submission traversal. For example, rather than performing an ad-hoc traversal of child components to make sure they are hidden, we can simply add an ephermal state value of
conditionallyHidden
to the component and make sure to pass the component as the parent to subsequent child components.To enable this concept, this PR:
registerEphermalState
andresetEphermalState
methods to utilities;eachComponent
intoeachComponentData
to ensure that layout components are passed through to child components as theparent
; andBreaking Changes / Backwards Compatibility
n/a
Dependencies
n/a
How has this PR been tested?
Wrote automated tests and ensured that formiojs, formio, and formio-server tests are passing.
Checklist: