A switch between options keeps a scalar the new option holds
Detect
- In your schema: a string, number or boolean field with
anyOforoneOfoptions that each describe the value, such as options that differ inminLength,maximumordefault. - In your tests: a switch between such options that expects the value cleared or replaced with the new option's
default.
Change
A switch between options keeps a string, number or boolean the new option holds, as it keeps an array (#5944). With s: { type: 'string', anyOf: [{ title: 'Short', maxLength: 10 }, { title: 'Long', minLength: 2, default: 'long' }] } and the data { s: 'abcd' }, select Long. Before: { s: 'long' }. After: { s: 'abcd' }.
- A value the new option's type can't hold, or its
constorenumleaves out, is dropped. - A value that is still the old option's
default,constor onlyenumvalue takes the new option'sdefaultorconst. Where that option declares neither, the value stays if the option'senumor constant options list it, and is dropped otherwise. - A
readOnlyoption with adefaultorconsttakes it, as before.
Update the tests and stored values that expect the value cleared or replaced with the new option's default.
Verify
- After a switch, the field holds the value the user typed where the new option accepts it, and the new option's
defaultwhere the value was the old option's.
Also read: