Set blur, focus and change in InternalFieldState when registerField is called.
If mutator creates a new field in MutableState for keeping the field state of a renamed field, set the blur, focus and change function of InternalFieldState when registerField is called.
This is needed by react-final-form-array because of this sequence of events as shown in https://github.com/final-form/final-form-arrays/issues/58
- FieldArray registers foo
- Field registers foo[0].a
- Field registers foo[1].b
- call
removemutator to remove foo[0] - in order to keep field states (touched, visited etc),
removemutator copies the field foo[1].b to foo[0].b. Note that there isn't any input fields subscribed to foo[0].b - FieldArray unmounts Field foo[1].b
- Field foo[0].a gets re-rendered, runs the useEffect clean up on foo[0].a and registers foo[0].b
Before this pull request, blur, focus and change would be undefined because the mutator is not able to set these functions because mutators do not have access to form. The Field foo[0].b would then error out and won't respond to input
This pull request ensures blur, focus and change are set when registerField is called.
Fixes final-form/react-final-form-arrays#127
Codecov Report
Merging #393 (a0b892e) into master (9c732e2) will not change coverage. The diff coverage is
100.00%.
@@ Coverage Diff @@
## master #393 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 12 12
Lines 591 591
Branches 124 127 +3
=========================================
Hits 591 591
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/FinalForm.js | 100.00% <100.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 9c732e2...33e551f. Read the comment docs.
Any eta for when this will be merged? Dragging and dropping with nested field arrays is rather broken right now. @erikras