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<
16711671 const prevTouched = this . state . meta . isTouched
16721672 if ( ! prevTouched ) {
16731673 this . setMeta ( ( prev ) => ( { ...prev , isTouched : true } ) )
1674- this . validate ( 'change' )
16751674 }
16761675 if ( ! this . state . meta . isBlurred ) {
16771676 this . setMeta ( ( prev ) => ( { ...prev , isBlurred : true } ) )
Original file line number Diff line number Diff line change @@ -2479,4 +2479,25 @@ describe('field api', () => {
24792479
24802480 expect ( field . getMeta ( ) . errorSourceMap . onChange ) . toEqual ( 'field' )
24812481 } )
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+ } )
24822503} )
You can’t perform that action at this time.
0 commit comments