Remove property from state

Hello,

I wanted to create a renderer/control that would be able to add, remove and update properties of an object.

Let’s say the JSON Schema is something very permissive like

{
“type”: “object”,
“minProperties”: 1
}

I wanted to take advantage of DispatchPropsOfControl.handleChange(), it seems like I can add a property but I didn’t find a way to remove it. Setting the value to undefined didn’t help.

Is there a way to achieve this?

Hi @JBBianchi, you can definitely unset values via handleChange, i.e. handleChange(your-path, undefined) should work. Can you give some more context where this doesn’t work for you? How does the data object look like before and after and which path are you handing over to handleChange?

Hello @sdirix , thanks for you reply. I think my problem lies more at the level of props.data in mapAdditionalProps rather than the “global” data.

Here is an example of the use case github[DOT]com/JBBianchi/jsonforms-angular-seed/blob/master/src/app/edit-object.renderer.ts#L105

For instance, the data looks like this {"examples": {"object": {"hello": "world"}}}

If I call handleChange('examples.object.hello', undefined);, the global data looks like this
{"examples": {"object": {}}} (so that’s good)
But in mapAdditionalProps(props), I have props.data as {"hello": undefined} where I expected {}.

Hi @JBBianchi, this sounds like a bug. I would expect that the hello key is no longer passed down after it’s gone. We can take a look next week.

I’ll open an issue on github then. Thanks for your support.

edit: issue #1790 opened