final-form / final-form

🏁 Framework agnostic, high performance, subscription-based form state management

Home Page:https://final-form.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reacting to onSubmit Promise rejection

taras-yurts opened this issue · comments

Submitting a bug report or a feature request:

Technically a feature request based on the contradiction with docs wording

Current behavior:

Currently, the form state doesn't change if there is some Promise rejection in the onSubmit handler, moreover submitSucceeded property turns true if that happens. Even though, according to the docs, there is a statement saying 'leaving rejection for when there is a server or communications error' and it seems that the form should consider some handling for rejection(server or communications error) case.

Expected behavior:

From the docs it seems that in case of some rejection(server or communications error) in the submit handler there should be some forms property or handler reacting to that and at least the form's submission shouldn't be considered as succeeded.

Environment:

react-final-form: 6.5.9
final-form: 4.20.7
node: 16.14.2
npm: 8.1.4

OS: Windows
Browser: Chrome 106.0.5249.91

Yeah, setting submitSucceeded = true after request (and promise) failure is a surprising behavior. Is it designed to be this way or is it a bug?

I'd rather expect setting submitFailed = ture. In a case submitFailed is reserved only for a case when request promise is resolved with an error object then it is better to not change form state at all. Currently, final-form behaves as if request was successful.