Repository navigation
fix: submit form on Enter in a single number input - #1345
Merged
snowystinger merged 1 commit intoNov 18, 2026
Merged
snowystinger merged 1 commit into
snowystinger merged 1 commit into
Conversation
Enter in the only field that blocks implicit submission submits the form, but number inputs were missing from the types that can trigger it. Chromium, Firefox and WebKit all submit in this case. Closes testing-library#1074
|
🎉 This PR is included in version 14.6.13 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Pressing Enter in a form's only number input doesn't submit the form (#1074):
Why
SubmitSingleInputOnEnterlists the input types where Enter submits a form that has no submit button, andnumberis missing from it, as pointed out on the issue. Since #1340 a number input already counts as a field that blocks implicit submission, so it could stop another field from submitting the form but couldn't submit it itself.I checked the browsers with Playwright (Chromium 159, Firefox 159, WebKit 27.2). All three submit on Enter in a lone number input, and none do when the form has a second text field. I also checked
date,timeanddatetime-local, which are inBlockImplicitSubmissionbut not in this list: none of the three browsers submit from those, so I left them out.How
Added
'number'toSubmitSingleInputOnEnter, plus tests:user.keyboard('42{Enter}');The two submit tests fail without the change. The full Jest suite passes, and
test:toolboxgives the same results asmainapart from the three new tests, which pass in every environment.Checklist
Closes #1074
Written with Claude Code; I reviewed the changes and ran the full suite locally.