@@ -163,9 +163,18 @@ class Field extends React.Component<FieldProps, FieldState> implements FieldEnti
163
163
const prevValue = this . getValue ( prevStore ) ;
164
164
const curValue = this . getValue ( ) ;
165
165
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
+
166
175
switch ( info . type ) {
167
176
case 'reset' :
168
- if ( ! namePathList || ( namePathList && containsNamePath ( namePathList , namePath ) ) ) {
177
+ if ( ! namePathList || namePathMatch ) {
169
178
// Clean up state
170
179
this . touched = false ;
171
180
this . validatePromise = null ;
@@ -181,7 +190,7 @@ class Field extends React.Component<FieldProps, FieldState> implements FieldEnti
181
190
break ;
182
191
183
192
case 'setField' : {
184
- if ( namePathList && containsNamePath ( namePathList , namePath ) ) {
193
+ if ( namePathMatch ) {
185
194
const { data } = info ;
186
195
if ( 'touched' in data ) {
187
196
this . touched = data . touched ;
@@ -205,7 +214,7 @@ class Field extends React.Component<FieldProps, FieldState> implements FieldEnti
205
214
*/
206
215
const dependencyList = dependencies . map ( getNamePath ) ;
207
216
if (
208
- ( namePathList && containsNamePath ( namePathList , namePath ) ) ||
217
+ namePathMatch ||
209
218
dependencyList . some ( dependency => containsNamePath ( info . relatedFields , dependency ) )
210
219
) {
211
220
this . reRender ( ) ;
@@ -222,12 +231,12 @@ class Field extends React.Component<FieldProps, FieldState> implements FieldEnti
222
231
* - else to check if value changed
223
232
*/
224
233
if (
225
- ( namePathList && containsNamePath ( namePathList , namePath ) ) ||
234
+ namePathMatch ||
226
235
dependencies . some ( dependency =>
227
236
containsNamePath ( namePathList , getNamePath ( dependency ) ) ,
228
237
) ||
229
238
( typeof shouldUpdate === 'function'
230
- ? shouldUpdate ( prevStore , values , info )
239
+ ? shouldUpdate ( prevStore , values , 'source' in info ? { source : info . source } : { } )
231
240
: prevValue !== curValue )
232
241
) {
233
242
this . reRender ( ) ;
0 commit comments