In prepare omen condition the categories are dynamic, and the first category is set as the default in the dropdown controller. This changes the dirtyFields and makes the form dirty, a little hack to solve this is to check if the callback onClick was called with category not initialized and avoid making that field dirty, but this is only possible with react-hook v6, in v5 the only possible option is related to validate the form after the change (third parameter in setValue).
So I've to use a bigger hack, track the behaviour explained above with a state, and checking if the only dirtyField is category, but for some reason, the useMemo doesn't run for other fields. I thought it was related to the dirtyFields set not having different identities in the shallowEqual comparison of the hook, so once the isDirtyOmenCondition (that makes the hook run) is true, the useMemo stops running.
A possible option is to use reset to only reset dirty in the first case but I didn't try that yet.
Closes #744
In prepare omen condition the categories are dynamic, and the first category is set as the default in the dropdown controller. This changes the
dirtyFields
and makes the formdirty
, a little hack to solve this is to check if the callbackonClick
was called withcategory
not initialized and avoid making that field dirty, but this is only possible with react-hook v6, in v5 the only possible option is related to validate the form after the change (third parameter insetValue
).So I've to use a bigger hack, track the behaviour explained above with a state, and checking if the only dirtyField is
category
, but for some reason, theuseMemo
doesn't run for other fields. I thought it was related to thedirtyFields
set not having different identities in the shallowEqual comparison of the hook, so once theisDirtyOmenCondition
(that makes the hook run) istrue
, theuseMemo
stops running.A possible option is to use
reset
to only reset dirty in the first case but I didn't try that yet.