-
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
fixing child components being displayed when they should be removed when clearOnHide is set #120
Conversation
…hen clearOnHide is set
const skipOnServer = (context: ConditionsContext): boolean => { | ||
const { component, config } = context; | ||
const clearOnHide = component.hasOwnProperty('clearOnHide') ? component.clearOnHide : true; | ||
if (config?.server && !clearOnHide) { | ||
// No need to run conditionals on server unless clearOnHide is set. | ||
return true; | ||
} | ||
return false; | ||
}; |
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.
no longer used
// the path set here is not the absolute path, but the path relative to the parent component | ||
scope.conditionals?.push({ path: getComponentPath(comp, compPath), conditionallyHidden: true }); |
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.
this sets a partial path to the parent <parent-key>.<field-key>
not an absolute path
const conditionallyHidden = (scope as ConditionsScope).conditionals?.find((cond) => { | ||
return cond.path === path; | ||
return path.includes(cond.path); |
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.
the path set in the conditionals is partial, relaxing the check from exact match to component path contains the conditional path
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.
lgtm
fixing child components being displayed when they should be removed when clearOnHide is set
Link to Jira Ticket
https://formio.atlassian.net/browse/FIO-8537
Description
The issue was that fields that should have been hidden on the submission were
What changed?
two things changed:
conditionalProcess
function there was a check to see if clearOnHide was checked before setting the conditional fields in the context scope. This was removed.clearHiddenProcess
function, the path in the conditional scope entries were checking the complete path of the component to determine if the submission data should be removed. However, the path being set in scope conditional array is a relative path from the parent, and therefore skipped. The change was to do a partial match on the conditional path to see if it should be omitted.Breaking Changes / Backwards Compatibility
Use this section to describe any potentially breaking changes this PR introduces or any effects this PR might have on backwards compatibility
Dependencies
None
How has this PR been tested?
unit tests
Use this section to describe how you tested your changes; if you haven't included automated tests, justify your reasoning
Checklist: