Skip to content
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

submitSucceeded is set on redux-form/STOP_SUBMIT #2260

Closed
theKashey opened this issue Dec 10, 2016 · 12 comments
Closed

submitSucceeded is set on redux-form/STOP_SUBMIT #2260

theKashey opened this issue Dec 10, 2016 · 12 comments

Comments

@theKashey
Copy link

  1. Get a form with onSubmitHandler, that will return rejected promise
  2. Do remote submit.

Event flow:

redux-form/START_SUBMIT
submitting: true
redux-form/STOP_SUBMIT
submitting: undefined
submitSucceeded: true
redux-form/SET_SUBMIT_FAILED
submitSucceeded: undefined
submitFailed: true

@mykyta-shulipa
Copy link
Contributor

confirm, promise rejection is not working (

@cdaringe
Copy link

cdaringe commented Dec 16, 2016

are you confident that your form looks like...

<Form onSubmit={handleSubmit(doAsyncSubmit} />

vs

<Form onSubmit={doAsyncSubmit} />?

@theKashey
Copy link
Author

theKashey commented Dec 16, 2016

@cdaringe - no, for remote submit you have to use onSubmit prop of reduxForm.
So

reduxForm({
 onSubmit:() => Promise.reject()
}, ({handleSubmit})<form onSubmit={handleSubmit}>...</form>);

The problem is not how onSubmit work. It work fine.
The problem occurs then you observing state (see #2289).
You will have a moment then your failed form is succeeded!

@cdaringe
Copy link

ah, looks like both syntaxes are equivalent, http://redux-form.com/6.3.1/docs/api/ReduxForm.md . anyway, bummer!

@danielrob
Copy link
Collaborator

@theKashey this issue is getting quite old, could you confirm that it still exists?

@theKashey
Copy link
Author

@danielrob - according to http://redux-form.com/7.0.3/examples/remoteSubmit/ - everything is ok.
Look like issue was solved.

@pacoccino
Copy link

I confirm that even with 7.0.3 we still have this issue.
When onSubmit is called and return a rejected promise, the event STOP_SUBMIT sets submitSucceeded to true before that SET_SUBMIT_FAILED sets it to false and submitFailed to true

@pacoccino
Copy link

As far as I can read on :
https://github.com/erikras/redux-form/blob/171ed689cf998774c39bcd435d73dd8228cb7e02/src/createReducer.js#L391
and
https://github.com/erikras/redux-form/blob/0975a24c5ec3e82302cf2141f79ba2c46814de48/src/handleSubmit.js#L68

This happens when the rejection object is not an instance of SubmissionError.
I think that the submitSucceeded should not be passed to true when the Promise is rejected, even if we don't throw a SubmissionError instance.
(The reducer thinks it's not an error otherwise)

@stefan-dimitrov
Copy link
Contributor

Seems like it's a leftover from issue #853 (pr #1428). I guess back then the setSubmitSucceeded action was not implemented.
So I believe now this behavior should be removed from stopSubmit.

@stefan-dimitrov
Copy link
Contributor

I made a pull-request with a fix - #3830

@erikras
Copy link
Member

erikras commented Mar 2, 2018

Published fix in v7.3.0.

@lock
Copy link

lock bot commented Mar 2, 2019

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.

@lock lock bot locked as resolved and limited conversation to collaborators Mar 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants