Omit Extra Data not behaving as expected on submit for allOf (if then) schemas along with additionalProperties set to false blocking form submission #4165
Labels
awaiting response
bug
duplicate issue
This issue is a duplicate of another one
if-then-else
Issues related to handling JSON Schema if/then/else
possibly close
To confirm if this issue can be closed
Prerequisites
What theme are you using?
mui
Version
5.18.1
Current Behavior
Form has two params - omitExtraData and liveOmit
If both are set to true, any schema changes occurring through allOf (if-then) will remove the previous data (schema and form data) onChange
If omitExtraData alone is set to true, it is not performing the same action onSubmit. Due to this, the live validation is throwing an error indicating the 'then' schema is not matching because the previously selected 'then' schema is not being removed, blocking the users from submitting the form.
Expected Behavior
If omitExtraData alone is set to true, it is expected to function properly during onSubmit just like the combination of omitExtraData and liveOmit performs during onChange.
At least that's what I understand from the documentation.
Steps To Reproduce
In https://rjsf-team.github.io/react-jsonschema-form/, I tried the following allOf (if-then) schema with additionalProperties:false
It works when both liveOmit and omitExtraData is set to true but with just omitExtraData, it blocks the user from submitting the form
omitExtraData_onSubmit_Behavior.mp4
{ "type": "object", "properties": { "animal": { "type": "string", "enum": [ "Cat", "Fish" ] } }, "required": [ "animal" ], "allOf": [ { "if": { "properties": { "animal": { "const": "Cat" } } }, "then": { "properties": { "food": { "type": "object", "properties": { "catFoodItems": { "type": "array", "items": { "type": "string" } } }, "additionalProperties": false, "required": [ "catFoodItems" ] } } } }, { "if": { "properties": { "animal": { "const": "Fish" } } }, "then": { "properties": { "food": { "type": "object", "properties": { "fishFoodOptionA": { "type": "string" }, "fishFoodOptionB": { "type": "string" } }, "additionalProperties": false, "required": [ "fishFoodOptionA", "fishFoodOptionB" ] } } } } ] }
Environment
Anything else?
omitExtraData_onSubmit_Behavior.mp4
The text was updated successfully, but these errors were encountered: