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

Submit form on Enter even if no submit-like button was found #2613

Merged
merged 3 commits into from Jul 25, 2023

Conversation

RobinMalfait
Copy link
Collaborator

This PR further improves the form compatibility by using form.requestSubmit() when a submit-like button wasn't found in the first place. We still want the other code, otherwise potential e.preventDefault() inside the onClick of the actual submit button wouldn't be called.

It's only if we can't find a submit button that we want to try the form.requestSubmit() way.

We can't use the form.submit() function, because then the form will be submitted without going through onSubmit listeners on the form itself.

Fixes: #2611

@vercel
Copy link

vercel bot commented Jul 25, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
headlessui-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 25, 2023 1:45pm
headlessui-vue ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 25, 2023 1:45pm

@RobinMalfait RobinMalfait changed the title Submit form on Enter even if no submit button was found Submit form on Enter even if no submit-like button was found Jul 25, 2023
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.

Pressing Enter for form submit inCombobox did not work properly
1 participant