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

[Feature]: Form onFormChange and accompanying hook. #311

Open
zachrip opened this issue Aug 2, 2023 · 2 comments
Open

[Feature]: Form onFormChange and accompanying hook. #311

zachrip opened this issue Aug 2, 2023 · 2 comments

Comments

@zachrip
Copy link

zachrip commented Aug 2, 2023

What is the new or updated feature that you are suggesting?

I would like to have an onFormChange handler that is aware of all fields in the form. Currently there is no way to do this if you make use of custom components as they don't emit onChange events.

<ValidatedForm onFormChange={form => {
  // can access the same values as the useFormContext hook
}}>
  ...
</ValidatedForm>

Why should this feature be included?

It makes it possible to do some things that aren't currently possible (ergonomically). In my case I want to submit the form every time it changes.

@airjp73
Copy link
Owner

airjp73 commented Aug 11, 2023

This seems reasonable. I think just having a useFormChange hook is probably enough for a first pass. My thinking is we would listen to any regular change event or change to a controlled field and invoke the handler with the entire FormData object. I'm not sure when I'll have time to get around to this, but I'm happy to provide guidance if you want try making a PR for this.

@khairulhaaziq
Copy link

I really support this idea, for example I have a 'save' button and it would be reasonable for the button to be disabled if it is the same as the previous saved value. @airjp73 Is there a workaround currently for this?

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

3 participants