Closed joelhooks closed 7 years ago
I don't know what, if any, the ramifications are for this, but the field is definitely touched and dirty at this point.
https://github.com/eggheadio/formik/commit/a86ac25c4c15f6cdc60a734c691084fc85ef6f23
@joelhooks Yeah I think this part of the API could use some love or better docs:
dirty
means at least one field has been touched
touched
is set on blur
, setTouched
, and setFieldTouched
in Formik (regardless of validateOnChange
or validateOnBlur
)isValid
is IMHO biased toward the way we do forms at The Palmer Group (i.e. we only show errors if a field has been touched). @eonwhite Going forward it might make sense to be more explicit and introduce:
hasErrors
: at least one error existshasTouched
: at least one field has been touchedhasChanged
: values are not deeply equal to initial values
In the meantime, @joelhooks you can add these yourself with a tiny wrapper like so:
const EggheadFormik = ({ render, ...props }) =>
<Formik
{...props}
render={p => render({...p, hasChanged: !deepEqual(p.values, p.initialValues)})}
/>
@joelhooks Here's a demo of how I would go about it https://codesandbox.io/s/jn00j0prpv
I'll just maintain a fork. Thanks @jaredpalmer!
I've got a relatively simple form that has a
textarea
. When I load the form and type into it, while theerrors
object updates to show that errors exist, theisValid
property doesn't change until Iblur
.When I refocus the input and type it updates
isValid
as expected.https://codesandbox.io/s/93406xym0y
This occurs in the README examples as well, and I'm wondering if my expectations aren't correct.