fix(case): child at risk checkbox being set to array [CHI-3321] #2957
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.
TODO:
Description
This PR fixes the bug described in the ticket linked below, where checkin the "child at risk" checkbox might end setting it's value as
['on']
or[ ]
, rather than the expectedtrue
/fase
values.The root cause seems to be how react hooks forms registers a component: if multiple checkbox components are registered under the same name, it's internal value will be set to an array. The exact cause of why this is being registered multiple times is not clear to me, but the changes I've made in this PR fix the issue since the initial values are set only once to the working copy, when the form component mounts. On top of this, I think the internal form using
workingCopy
as the initial value could cause some issues, as the first mount won't have a working copy at all.To replicate the bug:
false
.['on']
state.You should be able to replicate this bug in
master
but not in this branch.Checklist
Other Related Issues
None
Verification steps
AFTER YOU MERGE
You are responsible for ensuring the above steps are completed. If you move a ticket into QA without advising what version to test, the QA team will assume the latest tag has the changes. If it does not, the following confusion is on you! :-P