redux-form icon indicating copy to clipboard operation
redux-form copied to clipboard

Why using handleSubmit doesn't trigger `@@redux-form/SUBMIT`?

Open Sajam opened this issue 4 years ago • 0 comments

Subject of the issue

We have a middleware that checks if files are still uploading (to a different/separate endpoint than the form is submitted to) and prevent submitting the form if so. It checks if the action is @@redux-form/SUBMIT and if files are still uploading it doesn't execute next action. It looks pretty much like this (simplified):

if (action.type === actionTypes.SUBMIT) {
    if (!isUploading) {
        return next(action);
    }

    Snackbar.info('File upload not completed - please wait.');
}

When we use handleSubmit as a submit action, the @@redux-form/SUBMIT action is not fired and middleware doesn't work. When we use submit it works (generates @@redux-form/SUBMIT action).

It's a bit weird as the docs recommend using handleSubmit. Is there something wrong in using submit instead? Why handleSubmit is not triggering the @@redux-form/SUBMIT action?

Your environment

Software Version(s)
redux-form 8.3.6
redux 4.0.5
react-redux 7.2.2
react 16.14.0
react-dom 16.14.0
node 14.13.1
npm if using 6.14.8
yarn if using -
flow if using -
typescript if using -
Browser -
Operating System -

Steps to reproduce

As described above.

Expected behaviour

handleSubmit should probably also trigger @@redux-form/SUBMIT action.

Actual behaviour

handleSubmit is the recommended way of submitting the form but it's not triggering @@redux-form/SUBMIT compared to using submit.

Sajam avatar Nov 10 '20 15:11 Sajam