formio / formio.js

JavaScript powered Forms with JSON Form Builder
https://formio.github.io/formio.js
MIT License
1.89k stars 1.06k forks source link

FIO-7808: fixed an issue where conditional components inside conditional components lose their value after submission when they are on the same level with editGrid #5488

Closed TanyaGashtold closed 9 months ago

TanyaGashtold commented 9 months ago

Link to Jira Ticket

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

Description

What changed?

Added check that allows the conditions check of the parent component in setValue of the editGrid on the server side only in case when the parent component of the parent component is visible.

Why have you chosen this solution?

When the conditions check for editGrid parent component is run inside setValue and the parent component of the parent component is not visible, it unsets all values of conditional components as they are considered as invisible. So it appears that by the moment when the form conditions check starts, all conditional values on the same level with editGrid are already lost.

How has this PR been tested?

Manually + added tests

Checklist:

travist commented 9 months ago

Why is this behavior different on client vs. server? I am confused why there are checks for server execution in this fix.

TanyaGashtold commented 9 months ago

@travist , the issue is reproducible when the server option is passed. So, the values of conditional components disappear when we validate the submission on the server side. This is becouse in the clearOnHide (https://github.com/formio/formio.js/blob/4bcb87e1a1da46b178d32ae690e545e4e9154f66/src/components/_classes/component/Component.js#L2189) we have a check that removes the value from component when the component is not visible and the server option is passed.