-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIO-9255: fixed an issue where nested forms lose data after submission if some parent has conditional components #180
Conversation
…n if some parent has condtional components
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not immediately obvious to me what runClean
means - my understanding of this issue is that the pathing used by getComponent
is incorrect, is there an opportunity to just improve the overall pathing for nested forms? I need to discuss this ticket with CSRs anyway, so I'm moving it to Needs Review for now.
We will not be merging this pull request since it seems you are adding a lot of "flags" to get around the issue where you are expecting a "full path" when you are only getting a "local path" inside of the nested form. For any case where this is true, you should be wrapping the "local path" with the function called "getComponentAbsolutePath". This function will take the local path of a component (provided within an eachComponentData iteration inside of a nested form), and then give you the full absolute path of that component, which makes sense to allow "getComponent" to work by providing the absolute path. https://github.com/formio/core/blob/master/src/utils/formUtil/index.ts#L190 You may also take a look at the work done here #162. It seems this was resolving a ticket where a "similar" issue was found with the paths within Nested Forms. |
@brendanbond , @travist , let me explain what is happening in my use case.
General description of the bug: When the process is started, it iterates through the components using 'eachComponentData' and a relative path is added to each component. Real example: Lets imagine we have the following form structure:
Form 4 components:
Form 5 components:
Lets imagine we submit this form with the following values: The eachComponentData iterates the Form1 components in the following order: (1) nested2 - (2) nested3 - (3) nested4 - (4) nested4.selectForm4 - (5) nested4.textFieldForm4 - (6) nested4.textAreaForm4 - (7) nested5 - (8) nested5.numberForm5. Everything works as expected until iteration (5). The nested4.textFieldForm4 has a simple condition. When checking the condition, getComponent overrides paths for all form components to the absolute one. When nested4.textAreaForm4 (6) is processed, its parent components have absolute path (not the relative one as expected). Because of it, getComponentAbsolutePath calculates the absolute path wrongly inside filter process (as "nested2.data.nested3.data.nested2.data.nested3.data.nested4.data.textAreaForm4"). The right path should look like this: "nested2.data.nested3.data.nested4.data.textAreaForm4". Similarly, wrong absolute paths will be calculated for components from iteration 6-8 inside the filter process that will cause incorrect final data object structure. Solution: The root of the problem is that getComponent inside checkSimpleConditional overrides the relative paths by absolute paths that leads to the paths calculation issues inside other processors. In general, even not noting this issue, getComponent should just return a requested component and not create any side effects. In other words, it must be a clean function, that is function that does not change any input parameters. Let me know if you need any additional explanations. |
…data-if-some-component-are-conditional FIO-9255: fixed an issue where nested forms lose data after submission if some parent has conditional components
Link to Jira Ticket
https://formio.atlassian.net/browse/FIO-9255
Description
What changed?
The getComponent inside the simple conditional check overrides the component path that is initially set inside eachComponentData. That courses the nested forms components to have paths related to main form (not the local root how it is expected). That made the filters incorrectly set data into filtered submission object. This PR made so that getComponent works clean and did not change component objects as the only purpose of the getComponent is to return the requested component.
How has this PR been tested?
Manually + tests
Checklist: