Skip to content

submitOnChange validates form with previous values #72

@chawes13

Description

@chawes13

Expected: On change of an input, validations are run and the form is submitted (if no validations failed)
Actual: On change of an input, validations are run against the previous values and the form does not submit

Sandbox: https://codesandbox.io/s/redux-form-synchronous-validation-forked-uborp?file=/SyncValidationForm.js (type a single letter into the username input)

Related redux-form issues: redux-form/redux-form#537, redux-form/redux-form#4177

Suggested solution: Wrap props.submit() in a timeout to ensure that the form has the latest values
Workaround: Instead of passing submitOnChange: true to lpForm, we can override the change handler like so

onChange: (_values, _dispatch, props) => {
        setTimeout(props.submit, 0)
    },

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions