Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible workaround react-hook-form v5 limitation #845

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

hpmaxi
Copy link
Contributor

@hpmaxi hpmaxi commented Feb 12, 2021

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 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.

@hpmaxi hpmaxi changed the title Possible workaround react-hooks v5 limitation Possible workaround react-hook-form v5 limitation Feb 18, 2021
…er into bug/dirty-before-leave-omen-condition
@ghost
Copy link

ghost commented Feb 18, 2021

Travis automatic deployment:
https://pr845--conditionaltokensexplorer.review.gnosisdev.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'Are you sure..' pop-up appears when open Prepare Omen condition page and then leave it
1 participant