Skip to content

fix: do not implicitly submit month and week inputs - #1355

Merged
snowystinger merged 2 commits into
testing-library:mainfrom
abu-tahir-0:fix/month-week-implicit-submission-1348
Dec 2, 2026
Merged

snowystinger merged 2 commits into
testing-library:mainfrom
abu-tahir-0:fix/month-week-implicit-submission-1348

Conversation

@abu-tahir-0

Copy link
Copy Markdown
Contributor

Problem

Pressing Enter in a form containing only a month or week input triggers implicit submission in user-event, unlike browser behavior for these controls.

Root cause

SubmitSingleInputOnEnter included month and week. They belong in BlockImplicitSubmission, where they already remain present, but not in the single-input allowlist.

Solution

Remove only month and week from SubmitSingleInputOnEnter and add regressions asserting that Enter produces neither submission nor a synthetic click.

Testing

  • npm test -- --runInBand tests/event/behavior/keypress.ts — 51/51 tests passed, independently rerun.
  • Agent verification: both new cases failed before the fix; full suite 55/55 suites, 581/581 tests, 79/79 snapshots passed; npm run validate -s passed.

Fixes #1348

These controls do not participate in single-input implicit submission.
Keep them blocking when other fields are present and add regressions for
both input types.

@snowystinger snowystinger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so I went down a rabbit hole with this one.

According to the spec, Chrome is in the wrong

If the form has more than one field that blocks implicit submission, then return.

They should submit if they are the only field in the form.

However, I found this issue https://issues.chromium.org/issues/40218227
Which points to this spec issue whatwg/html#7730
and has an approved PR from 2022 whatwg/html#7731 which I've bumped

The summary is that not only should the fields be able to implicitly submit if they are alone, but they should also not block submission for others.

We'll see if the bump over there stirs anything, otherwise I'm inclined to match the browser so that it's accurate to real life and therefor useful. Then we can update whenever the spec is updated and the browsers implement it.

One other thing is that Chrome currently does do the right thing and does not block implicit submission if there is a month input in the form
https://jsfiddle.net/cvhwbdkp/2/

So I think we'll want to remove them from the BlockImplicitSubmission

@abu-tahir-0

Copy link
Copy Markdown
Contributor Author

Thanks for digging into this — that's really helpful context.

I've updated the PR to match the browser behavior you described in 9cfe814:

  • month and week are now removed from BlockImplicitSubmission, so a month/week input no longer prevents another field from triggering implicit submission.
  • They remain out of SubmitSingleInputOnEnter, so a lone month/week input still does not submit on Enter, matching current Chrome.
  • Tests: added month/week to the non-blocking-controls submission cases, removed them from the "another blocking input" cases, and kept the single-input no-submit regressions.

Full keypress suite passes (51/51). If the whatwg/html PR you bumped lands and browsers start submitting for a lone month/week field, moving them into SubmitSingleInputOnEnter should be the only follow-up needed.

@snowystinger snowystinger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for updating

@snowystinger
snowystinger merged commit b2f1967 into testing-library:main Dec 2, 2026
2 checks passed
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 14.6.14 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enter in a lone month or week input submits the form, but Chromium doesn't

2 participants