-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Prerequisites
- I have searched the existing issues
- I understand that providing a SSCCE example is tremendously useful to the maintainers.
- I have read the documentation
- 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.24.7
Current Behavior
This problem is caused by anyOf
fields being reset when the Form's onSubmit
handler is executed.
This causes both the anyOf
user selection option to be reset to the default first one, and any input data from the selected anyOf
subschema to be lost.
This is very annoying, as the async
validation error may be caused by some value outside the anyOf
subschema altogether.
I have not found a way to avoid this problem.
Expected Behavior
When async
validation is performed (in the onSubmit
handler), any anyOf
field and subschema input should be retained.
Maybe a new prop could be introduced that would allow the Form to retain its input data even after the onSubmit
handler ran?
Or, alternatively...
Maybe the onSubmit
handler could return a boolean
that determines the clearing of the Form's input data. This way, failing additional async
validation could allow the developer to return a boolean signaling that the current input data should be kept in the form.
Steps To Reproduce
No response
Environment
Irrelevant for this issue
Anything else?
If anyone is aware of a way to avoid this anyOf
field value reset issue in this case, please share it.