react-jsonschema-form
react-jsonschema-form copied to clipboard
Omit Extra Data not behaving as expected on submit for allOf (if then) schemas along with additionalProperties set to false blocking form submission
Prerequisites
- [X] I have searched the existing issues
- [X] I understand that providing a SSCCE example is tremendously useful to the maintainers.
- [X] I have read the documentation
- [X] Ideally, I'm providing a sample JSFiddle, Codesandbox.io or preferably a shared playground link demonstrating the issue.
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
- OS: macOS 14.2.1
- Node: 20.10.0
- npm: 10.2.3
Anything else?
https://github.com/rjsf-team/react-jsonschema-form/assets/16612102/a3b55874-c887-4828-9e7c-7f5bee8f998d
Thanks for the report. I think this is a duplicate of #4109
This issue was closed because of lack of recent activity. Reopen if you still need assistance.