purescript-halogen-formless icon indicating copy to clipboard operation
purescript-halogen-formless copied to clipboard

formState.anyTouched

Open noisyscanner opened this issue 2 years ago • 4 comments

As discussed at https://discourse.purescript.org/t/formless-v4-questions-dirty-state-and-reinitialize-forms/3137/3

noisyscanner avatar Aug 02 '23 22:08 noisyscanner

The big question here is to decide what to do with ResetField. What happens if you touch only one field then reset it? Should anyTouched be false?

thomashoneyman avatar Aug 02 '23 23:08 thomashoneyman

Ahhhh good point. Unless we maintain a set of the keys of changed fields like touchedFields, and then anyTouched could just be a function like size touchedFields > 0? I'm guessing this would be a Set (Variant fields). Need to do a bit of homework on Variant still but happy to try this.

noisyscanner avatar Aug 03 '23 06:08 noisyscanner

It seems like we could also do a variation on the allTouched function that works on the FormObject which checks if any field is touched rather than all fields are touched. Perhaps that’s an easier route.

thomashoneyman avatar Aug 03 '23 12:08 thomashoneyman

Wouldn't that rely on validation having run for the field though? So for it to work we'd need to set validateOnModify or validateOnChange for the form (or manually trigger validation), which may not be appropriate for all forms.

noisyscanner avatar Aug 03 '23 12:08 noisyscanner