Bug: submit -> submitSuccess -> reinitialize -> form.pristine == true => *edit_form* -> form.pristine == TRUE
#3 729 ouverte le 4 janv. 2018
Description
A Possible Bug with global form pristine field
What is the current behavior?
Given reduxForm with
- enableReinitialize = true
- keepDirtyOnReinitialize = false (default)
- onSubmitSuccess(res, dispatch, props) { dispatch(initialize(props.form.name, props.form.values) }
After the form was successfully submitted, it reinitializes and pristine becomes true again (very good). However, after I make any alteration to the form pristine keeps staying true.
Here is what goes on in the debugger:
// createReduxForm.js: 929
const shouldUpdateInitialValues = enableReinitialize (true) && initialized(true) && deepEqual(initialValues, stateInitial) (deepEqual returns false)
// true
A combination of shouldUpdateInitialValues == true and keepDirtyOnReinitialize == false always produces pristine = true a few lines below.
If I set keepDirtyOnReinitialize to true, the pristine prop gets evaluated correctly.
I wasn't able to grasp from the documentation how keepDirtyOnReinitialize affects global pristine, because it only refers to fields' pristine.
Thanks for the awesome piece of work.
What is the expected behavior?
I expect pristine to become false after form data is changed.