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

onChange event on checkbox that exposes the input synthetic event #3356

Open
spassvogel opened this issue Feb 2, 2025 · 0 comments
Open

Comments

@spassvogel
Copy link

spassvogel commented Feb 2, 2025

I'm using the Checkbox in a form together with server actions in NextJs. The form lives on a server component, the Checkbox is in a client child component.

What I would like to do is submit the form as soon as one of the values change, using the input type="checkbox"'s synthetic event to access the containing form, like so.

<Checkbox name="tos" onChange={(e) => e.currentTarget.form?.requestSubmit()} />

However, the only event the Checkbox seems to have is a onCheckedChange with a boolean, which is quite limited

the onClick on the Checkbox is not useful either, because at this point the underlying checkbox is not yet changed..

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

1 participant