File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -1671,7 +1671,6 @@ export class FieldApi<
1671
1671
const prevTouched = this . state . meta . isTouched
1672
1672
if ( ! prevTouched ) {
1673
1673
this . setMeta ( ( prev ) => ( { ...prev , isTouched : true } ) )
1674
- this . validate ( 'change' )
1675
1674
}
1676
1675
if ( ! this . state . meta . isBlurred ) {
1677
1676
this . setMeta ( ( prev ) => ( { ...prev , isBlurred : true } ) )
Original file line number Diff line number Diff line change @@ -2479,4 +2479,25 @@ describe('field api', () => {
2479
2479
2480
2480
expect ( field . getMeta ( ) . errorSourceMap . onChange ) . toEqual ( 'field' )
2481
2481
} )
2482
+
2483
+ it ( 'should not run onChange validation when onBlur is triggered' , ( ) => {
2484
+ const form = new FormApi ( {
2485
+ defaultValues : { a : '' } ,
2486
+ } )
2487
+ form . mount ( )
2488
+
2489
+ const field = new FieldApi ( {
2490
+ form,
2491
+ name : 'a' ,
2492
+ validators : {
2493
+ onChange : ( ) => 'Change error' ,
2494
+ onBlur : ( ) => 'Blur error' ,
2495
+ } ,
2496
+ } )
2497
+ field . mount ( )
2498
+
2499
+ field . handleBlur ( )
2500
+
2501
+ expect ( field . state . meta . errors ) . toStrictEqual ( [ 'Blur error' ] )
2502
+ } )
2482
2503
} )
You can’t perform that action at this time.
0 commit comments