testing-library / testing-library/user-event

userEvent.keyboard('{Enter}') does not trigger form submission in forms with radio group elements

Open
#1,255 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs investigation
Dominant language
TypeScript
Stars
2.3k
Forks
258
PR merge metrics
No merged PRs in 30d

Description

Reproduction example

https://stackblitz.com/edit/rtl-template-dg4qziej?file=src%2FApp.tsx

Prerequisites
  1. Render the form with radio group and text input field.
  2. Submit the form using user event keyboard while focus on input text element
  3. userEvent.keyboard('{Enter}') does trigger form submission
Expected behavior

userEvent.keyboard('{Enter}') does trigger form submission

Actual behavior

userEvent.keyboard('{Enter}') does not trigger form submission

User-event version

14.5.2

Environment

Testing Library framework: @testing-library/react@16.0.1

JS framework: react@18.2.0

Test environment: vitest@2.1.2

DOM implementation: jsdom@24.1.1

Additional context

Issue: userEvent.keyboard('{Enter}') does not trigger form submission when the form contains radio group elements.
Observation: Using fireEvent.submit successfully triggers form submission under the same conditions.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked StackBlitz reproduction in src/App.tsx and confirm the failure when a form contains a radio group and text input. Trace the userEvent.keyboard('{Enter}') path, then verify that Enter submits the form in this case without relying on fireEvent.submit.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.