@@ -830,7 +830,10 @@ export class FormStore {
830
830
const changedFields = fields . filter ( ( { name : fieldName } ) =>
831
831
containsNamePath ( namePathList , fieldName as InternalNamePath ) ,
832
832
) ;
833
- onFieldsChange ( changedFields , fields ) ;
833
+
834
+ if ( changedFields . length ) {
835
+ onFieldsChange ( changedFields , fields ) ;
836
+ }
834
837
}
835
838
} ;
836
839
@@ -856,6 +859,10 @@ export class FormStore {
856
859
// Collect result in promise list
857
860
const promiseList : Promise < FieldError > [ ] = [ ] ;
858
861
862
+ // We temp save the path which need trigger for `onFieldsChange`
863
+ const TMP_SPLIT = String ( Date . now ( ) ) ;
864
+ const validateNamePathList = new Set < string > ( ) ;
865
+
859
866
this . getFieldEntities ( true ) . forEach ( ( field : FieldEntity ) => {
860
867
// Add field if not provide `nameList`
861
868
if ( ! provideNameList ) {
@@ -883,6 +890,8 @@ export class FormStore {
883
890
}
884
891
885
892
const fieldNamePath = field . getNamePath ( ) ;
893
+ validateNamePathList . add ( fieldNamePath . join ( TMP_SPLIT ) ) ;
894
+
886
895
// Add field validate rule in to promise list
887
896
if ( ! provideNameList || containsNamePath ( namePathList , fieldNamePath ) ) {
888
897
const promise = field . validateRules ( {
@@ -961,7 +970,10 @@ export class FormStore {
961
970
returnPromise . catch < ValidateErrorEntity > ( e => e ) ;
962
971
963
972
// `validating` changed. Trigger `onFieldsChange`
964
- this . triggerOnFieldsChange ( namePathList ) ;
973
+ const triggerNamePathList = namePathList . filter ( namePath =>
974
+ validateNamePathList . has ( namePath . join ( TMP_SPLIT ) ) ,
975
+ ) ;
976
+ this . triggerOnFieldsChange ( triggerNamePathList ) ;
965
977
966
978
return returnPromise as Promise < Store > ;
967
979
} ;
0 commit comments