I have an array form that allows users to add up to three address types (work, home, alternate contact). There is a checkbox on the form to indicated which of these is the preferred address. If, for example, work is checked off, but the user decides that want to change that to home, when they check the home object’s preferred checkbox, the work checkbox should become unchecked.
I feel like this should be pretty straightforward, I’m simply checking if I certain type of custom checkbox has been interacted with and then modifying the data as needed in JsonForms’s onchange event (see below), as per this topic: Modifiying jsonformsData after onChange.
The console shows the data was correctly updated, but the custom checkbox never re-renderers with the correct state. Any ideas about why that may be happening?
<JsonForms
ajv={ajv}
schema={schema}
uischema={uischema}
data={data ?? ''}
renderers={renderers}
cells={materialCells}
validationMode="ValidateAndHide"
onChange={({ data, errors }) => {
let updatedData = data;
if (updatedControl) {
console.log('updatedControl', updatedControl);
updatedData = enforceRule(updatedControl, updatedData);
setUpdatedControl(undefined);
}
console.log('onChange', updatedData);
setData(updatedData);
setformErrors(errors);
}}
/>