@@ -163,9 +163,18 @@ class Field extends React.Component<FieldProps, FieldState> implements FieldEnti
163163 const prevValue = this . getValue ( prevStore ) ;
164164 const curValue = this . getValue ( ) ;
165165
166+ const namePathMatch = namePathList && containsNamePath ( namePathList , namePath ) ;
167+
168+ // `setFieldsValue` is a quick access to update related status
169+ if ( info . type === 'valueUpdate' && info . source === 'external' && prevValue !== curValue ) {
170+ this . touched = true ;
171+ this . validatePromise = null ;
172+ this . errors = [ ] ;
173+ }
174+
166175 switch ( info . type ) {
167176 case 'reset' :
168- if ( ! namePathList || ( namePathList && containsNamePath ( namePathList , namePath ) ) ) {
177+ if ( ! namePathList || namePathMatch ) {
169178 // Clean up state
170179 this . touched = false ;
171180 this . validatePromise = null ;
@@ -181,7 +190,7 @@ class Field extends React.Component<FieldProps, FieldState> implements FieldEnti
181190 break ;
182191
183192 case 'setField' : {
184- if ( namePathList && containsNamePath ( namePathList , namePath ) ) {
193+ if ( namePathMatch ) {
185194 const { data } = info ;
186195 if ( 'touched' in data ) {
187196 this . touched = data . touched ;
@@ -205,7 +214,7 @@ class Field extends React.Component<FieldProps, FieldState> implements FieldEnti
205214 */
206215 const dependencyList = dependencies . map ( getNamePath ) ;
207216 if (
208- ( namePathList && containsNamePath ( namePathList , namePath ) ) ||
217+ namePathMatch ||
209218 dependencyList . some ( dependency => containsNamePath ( info . relatedFields , dependency ) )
210219 ) {
211220 this . reRender ( ) ;
@@ -222,12 +231,12 @@ class Field extends React.Component<FieldProps, FieldState> implements FieldEnti
222231 * - else to check if value changed
223232 */
224233 if (
225- ( namePathList && containsNamePath ( namePathList , namePath ) ) ||
234+ namePathMatch ||
226235 dependencies . some ( dependency =>
227236 containsNamePath ( namePathList , getNamePath ( dependency ) ) ,
228237 ) ||
229238 ( typeof shouldUpdate === 'function'
230- ? shouldUpdate ( prevStore , values , info )
239+ ? shouldUpdate ( prevStore , values , 'source' in info ? { source : info . source } : { } )
231240 : prevValue !== curValue )
232241 ) {
233242 this . reRender ( ) ;
0 commit comments