-
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
Issues with focusOnFirstError and onSubmit #3827
Comments
@Sourcekot There's a lot going on here, so I'll need your help refining the reproduction to figure out what bugs there are, and where you might just need to make a few changes to your code to do what you want.
This definitely looks like a bug in RJSF to me!
Because it's in the body of the function component, and not wrapped in |
Sadly I think thats not a possibility. I've got some validation that need to fetch some information from my database. That's why I need extraErrors to do those async calls and if I remember it correctly the customValidate function can't be async. That's why I have it in my onSubmit. But maybe I'm not doing this correctly as I haven't found much about the async validation in the documentation.
It can't be in the onChange as I don't want those validations to be done on every single change. They should only be executed if the user presses the submit button. Regarding extraErrorsBlockSubmit: That might have been a misunderstanding on my side. As it was added in my previous issue (#3757) I thought I had to add it to fix my issue. Currently I see two options to somehow fix my issue but both aren't good solutions: a) I have to do my async call in the onChange which is not really an option as I don't want to call those that often or Is there any other way for me to set the extraErrors prior to the focusOnFirstError without calling it on every change? EDIT: I had no time to try it yet but could I maybe use customValidate with an inner async function like this?:
Currently I was using the onSubmit like this:
But isn't it the suggested way to add the templates? In the documentation (Doc Link) it is done pretty similar to my example. Could you give me an example of how it should be done with useEffect? |
Prerequisites
What theme are you using?
mui
Version
5.12.0
Current Behavior
Follow-up to #3757: Sadly my problems were only partially fixed and some new problems now occur:
Codesandbox: codesandbox.io/s/solitary-breeze-7ykd2f
Add a subentry and press submit. It will somehow close after the first submit so add a subentry again and submit again. This time you can see "undefined" in the console as the error object from the focusOnFirstError function.
One more thing: Why is the ErrorListTemplate reached every time I change something in the form? LiveValidate is not enabled so I thought this shouldn't happen.
Expected Behavior
Steps To Reproduce
see Current Behavior section.
Environment
Anything else?
No response
The text was updated successfully, but these errors were encountered: