Omit Extra Data not behaving as expected on submit for allOf (if then) schemas along with additionalProperties set to false blocking form submission #4165
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
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
https://github.com/rjsf-team/react-jsonschema-form/assets/16612102/b3697054-1325-44ef-8a39-cef0bd6d0100
{ "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?
https://github.com/rjsf-team/react-jsonschema-form/assets/16612102/a3b55874-c887-4828-9e7c-7f5bee8f998d