@@ -106,6 +106,9 @@ class Field extends React.Component<InternalFieldProps, FieldState> implements F
106106 */
107107 private touched : boolean = false ;
108108
109+ /** Mark when touched & validated. Currently only used for `dependencies` */
110+ private dirty : boolean = false ;
111+
109112 private validatePromise : Promise < string [ ] > | null = null ;
110113
111114 private prevValidating : boolean ;
@@ -189,6 +192,7 @@ class Field extends React.Component<InternalFieldProps, FieldState> implements F
189192 // `setFieldsValue` is a quick access to update related status
190193 if ( info . type === 'valueUpdate' && info . source === 'external' && prevValue !== curValue ) {
191194 this . touched = true ;
195+ this . dirty = true ;
192196 this . validatePromise = null ;
193197 this . errors = [ ] ;
194198 }
@@ -198,6 +202,7 @@ class Field extends React.Component<InternalFieldProps, FieldState> implements F
198202 if ( ! namePathList || namePathMatch ) {
199203 // Clean up state
200204 this . touched = false ;
205+ this . dirty = false ;
201206 this . validatePromise = null ;
202207 this . errors = [ ] ;
203208
@@ -222,6 +227,7 @@ class Field extends React.Component<InternalFieldProps, FieldState> implements F
222227 if ( 'errors' in data ) {
223228 this . errors = data . errors || [ ] ;
224229 }
230+ this . dirty = true ;
225231
226232 this . reRender ( ) ;
227233 return ;
@@ -304,6 +310,7 @@ class Field extends React.Component<InternalFieldProps, FieldState> implements F
304310 validateFirst ,
305311 messageVariables ,
306312 ) ;
313+ this . dirty = true ;
307314 this . validatePromise = promise ;
308315 this . errors = [ ] ;
309316
@@ -324,6 +331,8 @@ class Field extends React.Component<InternalFieldProps, FieldState> implements F
324331
325332 public isFieldTouched = ( ) => this . touched ;
326333
334+ public isFieldDirty = ( ) => this . dirty ;
335+
327336 public getErrors = ( ) => this . errors ;
328337
329338 // ============================= Child Component =============================
@@ -400,6 +409,7 @@ class Field extends React.Component<InternalFieldProps, FieldState> implements F
400409 control [ trigger ] = ( ...args : EventArgs ) => {
401410 // Mark as touched
402411 this . touched = true ;
412+ this . dirty = true ;
403413
404414 let newValue : StoreValue ;
405415 if ( getValueFromEvent ) {
0 commit comments