File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
packages/simplr-forms-core/src/stores Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -179,9 +179,29 @@ export class FormStore extends ActionEmitter {
179
179
public UpdateFieldValue ( fieldId : string , newValue : FieldValue ) : void {
180
180
this . State = this . State . withMutations ( state => {
181
181
const fieldState = state . Fields . get ( fieldId ) ;
182
+ const fieldPristine = ( newValue === fieldState . InitialValue ) ;
182
183
state . Fields = state . Fields . set ( fieldId , fieldState . merge ( {
183
- Value : newValue
184
+ Value : newValue ,
185
+ Pristine : fieldPristine
184
186
} as FieldState ) ) ;
187
+
188
+ if ( ! fieldPristine ) {
189
+ state . Form = state . Form . merge ( {
190
+ Pristine : false
191
+ } as FormState ) ;
192
+ } else {
193
+ let allFieldsPristine = true ;
194
+ state . Fields . forEach ( field => {
195
+ if ( field != null && ! field . Pristine ) {
196
+ allFieldsPristine = false ;
197
+ return false ;
198
+ }
199
+ } ) ;
200
+
201
+ state . Form = state . Form . merge ( {
202
+ Pristine : allFieldsPristine
203
+ } ) ;
204
+ }
185
205
} ) ;
186
206
187
207
this . emit ( new Actions . ValueChanged ( fieldId , newValue ) ) ;
You can’t perform that action at this time.
0 commit comments