A default an ancestor declares picks the anyOf or oneOf option
Detect
- In your schema: a field with
anyOforoneOfoptions and nodefaultof its own, inside an object whosedefaultgives it a value that the field'stypecan hold, its owntypeor one anallOfor anifgives it. - In your schema: an object field with
anyOforoneOfoptions and aconstof its own. - In your form data: no value for that field.
- In your tests or stored values: the form data such a form starts with, or a
getDefaultFormState()result for it.
Change
Under the default nestedDefaultsPrecedence: 'descendantWins', such a field started from the option that matches no data, usually the first, and a value that option doesn't hold was dropped. It now starts from the option the value matches, as it does with the value as its own default, in the form data or in an array's default (#5944). With this schema and no formData, the form started as { "pet": { "kind": "cat" } } and now starts as { "pet": { "kind": "dog" } }:
{
"type": "object",
"default": { "pet": { "kind": "dog" } },
"properties": {
"pet": {
"oneOf": [
{ "type": "object", "properties": { "kind": { "const": "cat" } } },
{ "type": "object", "properties": { "kind": { "const": "dog" } } }
]
}
}
}
The option's own defaults still win over the ancestor's, key by key, and an option's default for a key the ancestor leaves out is now filled in beside them.
An object field's own const picks the option the same way, over a default of the field's own. { "type": "object", "const": { "kind": "dog" }, "oneOf": [...] } with the options above started as { "kind": "cat" }, which the const rejects, and now starts as { "kind": "dog" }.
Where a ui:initialValue takes the place of either, the option its value matches is the one picked.
Update the tests and stored values that expect the earlier starting data. To start from another option, change the default, or give the field one of its own:
-"default": { "pet": { "kind": "dog" } },
+"default": { "pet": { "kind": "cat" } },
Verify
- The form starts on the option the ancestor's
default, the field'sconstor itsui:initialValuematches, with that value kept. - Keys the option's own defaults give are filled in beside the ancestor's.
Also read: