Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omit Extra Data not behaving as expected on submit for allOf (if then) schemas along with additionalProperties set to false blocking form submission #4165

Closed
4 tasks done
sahanaamurthy opened this issue Apr 15, 2024 · 2 comments · Fixed by #4228
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

Comments

@sahanaamurthy
Copy link

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

- OS: macOS 14.2.1
- Node: 20.10.0
- npm: 10.2.3

Anything else?

omitExtraData_onSubmit_Behavior.mp4
@sahanaamurthy sahanaamurthy added bug needs triage Initial label given, to be assigned correct labels and assigned labels Apr 15, 2024
@nickgros
Copy link
Contributor

Thanks for the report. I think this is a duplicate of #4109

@nickgros nickgros added awaiting response if-then-else Issues related to handling JSON Schema if/then/else duplicate issue This issue is a duplicate of another one and removed needs triage Initial label given, to be assigned correct labels and assigned labels Apr 19, 2024
@heath-freenome heath-freenome added the possibly close To confirm if this issue can be closed label Apr 19, 2024
Copy link

stale bot commented May 20, 2024

This issue was closed because of lack of recent activity. Reopen if you still need assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants