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

Imperative api reset() caused form onChange event fired for each field. #543

Open
huangc8606 opened this issue Aug 8, 2020 · 1 comment

Comments

@huangc8606
Copy link

For example I have a form with 3 input fields, then call formsy.reset({}), onChange event will be fired 3 times(each field will trigger one onChange event on Formsy component), so if I have 10 fields, onChange will be fired 10 times if I use reset function. And I believe this reset process should be batched and fire onChange event only after all fields' value are updated.
https://github.com/formsy/formsy-react/blob/master/src/Formsy.ts#L243

I added below if you click "Reset Model" you could see 3 lines output.
https://codesandbox.io/s/react-playground-6m7if?file=/index.js

@felixmosh
Copy link
Contributor

Debug info,
When calling reset() the following chain is triggered:

reset() -> forEach(input).resetValue -> input.setState(prestine) -> validate -> onChange

Looks like the flag canChange is not solving the issue.

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

No branches or pull requests

2 participants