-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[6.2.0] initialize(currentFormData) clears warnings and errors until the next onChange #2142
Comments
Dropping the |
after messing around with this for the later half of the day, removing that !deepEqual check doesn't solve it, that's just the first barrier. The second barrier exists inside The only solution I've come up with is to modify the way the ...
var result = empty; // clean all field state
// keep old warnings, they will get recalculated if the form values are different from current values
const warning = getIn(state, 'warning')
if (warning) {
result = setIn(result, 'warning', warning)
}
const syncWarnings = getIn(state, 'syncWarnings')
if (syncWarnings) {
result = setIn(result, 'syncWarnings', syncWarnings)
}
... This will persist the old warnings through the I've tested it locally with both cases and it seems to work fine, and it passes all current tests. Thoughts? I can whip up a PR if you approve. |
Fix published in |
Just added PR #2228 which solves the other part of this issue (errors not being persisted across initializations) |
@dfalt The reason I didn't add that in as well is because it to The only case where this would be possible is if you happen to fire |
@bmv437 You're right, after some more digging this is not a re-initialization issue. It actually appears to be an issue with the form's first initialization. I should probably open up a separate issue, but I'll clarify what I'm seeing here anyways. This issue is manifesting for a form which loads its
The problem lies in step 7 here. Our component is still aware of the original sync errors that we found in step 2, while our redux form state thinks there are no errors. Perhaps there is a better place to put the fix, but by making sure errors can pass through initialization (exactly how you solved with warnings) we solve the problem as well. |
any progress on this? i've the same prob as dfalt explained, sync errors if they're same they don't pass through initialization ;/ Edit: i've updated to v6.3, but the problem in my case, when the form is reinitialized the let formErrors = getFormSyncErrors('MenuForm')(state); is not updated, but if i understand correctly reinitialization shouldn't do that anyways? |
@mvirbicianskas this particular fix has been released in v6.3.2, however, I'm not sure I'm following what's going on in your example. I'd suggest upgrading to v6.3.2 to see if that does resolve your issue and if not perhaps provide some more information about your setup. How is it that you are reinitializing your form? Are you reinitializing with the same form values as it was initialized with or new form values? |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Ok, so I've tracked this bug all the way down to the cause, I just don't have a solution. I'd be happy to submit a PR if we can figure out a solution.
A little background:
in
src/reduxForm.js
,warnIfNeeded()
will always fireupdateSyncWarningsIfNeeded()
on initialRender (nextProps
===undefined
), but on subsequent renders, it will only fire the updates if!deepEqual(values, nextProps.values)
see the following copy of
warnIfNeeded
this makes sense for most cases, but what if you initialize the form using the current values of the form (in order to get a pristine state)?
Since the action handler for the
initialize
action starts from an empty state, warnings get cleared from the state. and since it's not initialRender, and the values of the form haven't changed, it won't re-calculate warnings.We need a way to the form to recalculate warnings even if the form has been initialized to it's current values in order to achieve a pristine state.
Technically there is a similar issue with sync errors and the
validateIfNeeded()
function, but you can't fire a submit on a form with errors anyway (hence why I'm using warnings).I'd love to get some discussion going around a solution, and like I said, I'd be happy to submit a PR with the final fix.
The text was updated successfully, but these errors were encountered: