-
Notifications
You must be signed in to change notification settings - Fork 409
Closed
Description
Describe the bug
When a schema with a oneOf property is rendered and loaded with a data set. The oneOf field always preselects the first items and may render data from the an incorrect option.
To Reproduce
UISchema:
{
"type":"object",
"properties":{
"quantity":{
"oneOf":[
{
"$ref":"#/definitions/unrangedQuantity"
},
{
"$ref":"#/definitions/rangedQuantity"
}
]
}
},
"definitions":{
"unrangedQuantity":{
"title":"Value",
"type":"object",
"properties":{
"value":{
"type":"number"
},
"unit":{
"type":"string"
}
},
"required":[
"value",
"unit"
]
},
"rangedQuantity":{
"title":"Range",
"type":"object",
"properties":{
"valueLow":{
"type":"number"
},
"valueHigh":{
"type":"number"
},
"unit":{
"type":"string"
}
},
"required":[
"valueLow",
"valueHigh",
"unit"
]
}
}
}
Data:
{
"quantity":{
"valueLow":1,
"valueHigh":10,
"unit":"kg"
}
}
Screenshot:
Expected behavior
The correct field is selected and populated. This may be potentially quite complicated due to the recursive nature. Ideally the data could be validated against each of the oneOf items and populate the first it validates against.
Browser (please complete the following information):
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
Used Setup (please complete the following information):
- Framework: React
- RendererSet: Material
Additional context
- JSONForms: 2.2.1-alpha.4