-
Notifications
You must be signed in to change notification settings - Fork 418
Description
Describe the bug
Given the following JSON schema, if the user sets a boolean value then switches the oneOf control to the array schema and adds an array item, the error TypeError: array.push is not a function is given.
{
"oneOf": [
{
"title": "Boolean",
"type": "boolean"
},
{
"title": "Array",
"type": "array",
"items": {
"type": "string"
}
}
]
}Expected behavior
The stored value should be reset and turned into an array so items can be added.
Steps to reproduce the issue
- Setup an app with @jsonforms/vue-vanilla renderers
- Supply the schema listed in the description above
- Set an array value
- Set a boolean value (notice the prompt to clear the data)
- Set an array value (notice there is no prompt to clear the data)
- Add an array item (notice the form does not change and an error is now present in the console)
Note: I don't think there needs to be prompt when switching away from a boolean value, but the data should be cleared.
Screenshots
No response
Which Version of JSON Forms are you using?
3.6.0
Package
Vue Vanilla Renderers
Additional context
I've recreated a OneOfRenderer component and found the issue can be resolved by the following change. It will need more in-depth testing, but this works for me.
// wrap useJsonFormOneOfControl with useVanillaControl
const input = useVanillaControl(useJsonFormsOneOfControl(props as ControlProps));
...
return {
// remove useVanillaControl wrapper from the returned input
...input,
...
}