File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -290,7 +290,9 @@ describe('Field', () => {
290290 { ...input }
291291 data-testid = "name"
292292 onBlur = { e => {
293- input . onChange ( e . target . value && e . target . value . toUpperCase ( ) )
293+ input . onChange (
294+ e . target . value && e . target . value . toUpperCase ( )
295+ )
294296 input . onBlur ( e )
295297 } }
296298 />
Original file line number Diff line number Diff line change @@ -119,7 +119,16 @@ function useField<FormValues: FormValuesShape>(
119119 ( event : ?SyntheticFocusEvent < * > ) => {
120120 state. blur ( )
121121 if ( formatOnBlur ) {
122+ /**
123+ * Here we must fetch the value directly from Final Form because we cannot
124+ * trust that our `state` closure has the most recent value. This is a problem
125+ * if-and-only-if the library consumer has called `onChange()` immediately
126+ * before calling `onBlur()`, but before the field has had a chance to receive
127+ * the value update from Final Form.
128+ */
122129 const fieldState = form . getFieldState ( state . name )
130+ // this ternary is primarily to appease the Flow gods
131+ // istanbul ignore next
123132 state . change (
124133 format ( fieldState ? fieldState . value : state . value , state . name )
125134 )
You can’t perform that action at this time.
0 commit comments