Hi, I’m having an issue with the JSONForms library when clearing a field with the x button. The problem is that when I delete the data, the field is automatically deleted. Is this intentional on the part of the library?
Below, I’ll give you more context about my app.
We have an app where JSON files are loaded and divided into “sections.” This way, we have shorter forms divided into topics.
This is our structure:
<JsonForms
schema={schema.properties?.[selectedSection]}
data={currentData}
renderers={customRenderers}
cells={materialCells}
onChange={({ data: updatedData }) => handleJsonFormsChange(updatedData)}
/>
const handleJsonFormsChange = (updatedData) => {
if (JSON.stringify(workingConfig) !== JSON.stringify(updatedData)) {
setWorkingConfig((prevConfig) => ({
...prevConfig,
[selectedSection]: updatedData,
}));
updateVisorConfigJson({
...workingConfig,
[selectedSection]: updatedData,
});
}
};
So, when someone deletes all the string field or push the “x”, the onChange callback executes and returns the updated json deleting the key:value modified. This behaviour brokes our functionality becouse we need allow empty key:value fields.
Here’s an example:
If you need more information, I’ll provide it.