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

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

Open
vinothkumar-tw opened this issue Jan 16, 2025 · 1 comment
Labels
bug Something isn't working needs investigation Someone has to do research on this

Comments

@vinothkumar-tw
Copy link

vinothkumar-tw commented Jan 16, 2025

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/[email protected]

JS framework: [email protected]

Test environment: [email protected]

DOM implementation: [email protected]

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.

@ph-fritsche
Copy link
Member

Thanks for contributing to this library.

On these input types Enter can trigger a submit:

const SubmitSingleInputOnEnter = [
'email',
'month',
'password',
'search',
'tel',
'text',
'url',
'week',
]

We currently check if the form only contains one <input> element, as a second e.g. <input type="text"> disables this behavior in the browser, but e.g. a <select> does not affect it. Looks like any input element which isn't on the list is ignored as well. Can we confirm this? Is this defined in specs?

@ph-fritsche ph-fritsche added needs investigation Someone has to do research on this and removed needs assessment This needs to be looked at by a team member labels Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs investigation Someone has to do research on this
Projects
None yet
Development

No branches or pull requests

2 participants