final-form / final-form-focus

🏁 Final Form "decorator" that will attempt to apply focus to the first field with an error upon an attempted form submission
MIT License
83 stars 15 forks source link

Use `form.getState()` directly instead of using subscriptions. #16

Open BowlingX opened 4 years ago

BowlingX commented 4 years ago

Hi :),

I was running into timing issues on async error handling (with final-form 4.18.6 and react-final-form 6.3.3). (The promise in onSubmit would resolve before / at the same time the subscription callback fires and would compare against a stale state. I'm not sure why the subscription is needed because we have access to the form state directly with getState().

This pull request adresses the issue of a potential stale state.

codecov[bot] commented 4 years ago

Codecov Report

Merging #16 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #16   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           5      5           
  Lines          44     40    -4     
  Branches       11     11           
=====================================
- Hits           44     40    -4
Impacted Files Coverage Δ
src/decorator.js 100% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update c26b46e...56dee29. Read the comment docs.

BowlingX commented 4 years ago

Any more information required to have this merged? :)

TylerRick commented 4 years ago

I like how this simplifies things. Any reason we shouldn't merge this, @erikras?

mishaberezin commented 3 years ago

@erikras Could you please give some feedback on this issue. We're having the same problem in our projects and have to use fork of this library with similar patch applied.