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
persistentSubmitErrors
has no effect when used together w/ sync validation
#3384
Comments
I guess I see why it's made the way it is, why it's trying to re-validate the entire form when one value changes. Some validators may rely on more than one value at the time and change in one field may make whole form valid, so redux-form revalidates everything. I haven't read all of the code, but I assume that is the logic behind current behavior. But the assumption that sync validation should outweight async one is probably wrong. I'd say server errors should be prioritized, at least with What I tried to do in that In #3380 I suggested introducing a builtin way of resetting certain fields if form is being rejected by the server. It probably would be an easy solution - clear fields, keep the errors, and it would solve my problem, but it's not universal. Maybe instead there should be a way of updating values so that previous validation errors will always outweight the sync validation, regardless of the Maybe I'm just trying to do it wrong? Maybe there's a simpler way I'm not seeing? |
And one more thing. It's confused that with the |
Okay, so this behavior only applies to form-level error and I see no good reason for this to happen. It doesn't do that with field validation. There are separate keys for Considering how form level errors and warnings are being passed to redux-form and how it's being fetched back from redux-store I don't really see why they couldn't be kept under This bug is a blocker for us and I'm currently trying to fix it all by doing the following:
And to improve form condition in
@erikras I'd like to hear your opinion on this. Maybe error/warning were stored like this for a reason? |
I'm also curious about this. |
I tried to fix it, but accidentally broke some other edge-case behavior covered by test suite and never tried to redesign my solution to account for that. Maybe I'll give it another shot this evening |
Looking through the tests I found this. I was able to get the persistent behavior by passing |
I'm able to remove |
So this was my take on this unconfident@ac752d3. I did what I suggested in my previous comment from December 15 - split Most of the tests were fixed in another commit on the same branch and for most of them all it took is to rename But there's one test that I didn't fix, because I simply don't know what would be the proper way to address it. Behavior defined by spec just doesn't seem right to me. It was introduced in d84aa7f to fix issue #2244. The code from the issue does not even use This comment describes what I would consider correct behavior:
but 5 hours later after posting this he changed his mind and decided to make resubmitting of invalid forms possible. ¯\_(ツ)_/¯ I mean, I can see one legitimate use case where this behavior could be desired: displaying network failures or something like code 500 from server through form-wide error, but I also see plenty of better ways to work around it without straight up ignoring presence of that submit error. Since it was @erikras decision I'd like to ask him to decide once again how this situation should be resolved. |
how naive I was |
Are you submitting a bug report or a feature request?
A bug
What is the current behavior?
persistentSubmitErrors
is being ignored by the reducer handlingUPDATE_SYNC_ERRORS
action, and any change to any field in a form with at least one sync validator attached erases global form error.Sandbox Link
What is the expected behavior?
Either there should be a way to update field values programmatically and preserve submit errors, or maybe it's just global error that should be treated differently, but I would expect that if
persistentSubmitErrors
was set to true and sync validators did not return a different error, the one returned by the server should still be displayed to the userThe text was updated successfully, but these errors were encountered: