-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Weird Json Schema oneOf behavior in RJSF #4449
Comments
I think a property similar to the useForm mode should be implemented to better solve this problem. after Live validation is turned on, the actual validation behavior is “onMount” |
Hi @JinYuSha0, how is useForm would fix this? do you know what is the underlying cause? Is there a workaround? I have also added an animated GIF that shows the actual bug. |
I took a look through this and I think the validation side is working as expected. When you switch to custom There does appear to be a bug with the defaults for the inner oneOf. When you switch from |
yes, I think you are correct, problem is that switching the inner oneOf causes an incomplet/empty values which causes the validation to fail. It is causing us lots of problems, do you think this is related to the structure of the schema? |
I think I found a solution, because I do the same thing. If you add
To the YYYY definition, everything works. You could hide |
Well, it worked for me briefly, then it stopped working again. I'll keep chewing on it. |
Getting rid of liveOmit seems to help, although there are still some issues. I agree that this does seem to have something to do with nested oneOf values |
Prerequisites
What theme are you using?
material-ui
Version
5.x
Current Behavior
I have the following schema which is rendered using react-jsonschema-forms framework. Link to playground here
Change the DropDown in the form (as shown in the image between XXXX and YYYY
The form seems to fail validation in rjsf especially when I switch the inner oneOf between the XxxxxType and YyyyyType definition. It always complains that it doesn't match between one of the two schemas and must have required property 'name'. I have tried different permutations of RJSF options and nothing seems to work.
Also tried discriminating using "if" that that didn't work. I have spent a lot of time trying to figure this out and I can't figure out the issue. Your help is much appreciated. Note that moving the inner oneOf to top level (removing the nesting) makes it work (see link in "expected behaviour").
Expected Behavior
I have tried moving the inner oneOf at the top level see playground and it works as expected.
Expecting the input to stay valid when switching between the inner oneOf definitions.
Steps To Reproduce
Go to playground... select "XXXXX" for second dropdown (UI is valid). Change the drop down to "YYYY" you will get errors
I have attached an animated GIF to show how to reproduce.
Note that
Environment
Anything else?
No response
The text was updated successfully, but these errors were encountered: