testing-library / testing-library/user-event
userEvent.click() on the label of a radio input does not cause it to become checked in firefox
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.3k
- Forks
- 258
- PR merge metrics
- No merged PRs in 30d
Description
Reproduction example
https://codesandbox.io/s/recursing-hoover-75289w?file=/src/App.js
Prerequisites
- Render an input type="radio with a linked label e.g.
<><label htmlFor="radio-foo">foo</label><input type="radio" id="foo" value="foo" /></> - Trigger a click on the label e.g.
await userEvent.click(screen.getByText('foo'))
Expected behavior
The radio input should become checked as it will in Chrome or Safari.
Actual behavior
In Firefox the radio input remains unchecked.
User-event version
14.0.0
Environment
Testing Library framework: @testing-library/dom@9.3.1
JS framework: react@18.2.0
Test environment: Originally discovered in a storybook interaction test but reproduced independent of any testing environment.
DOM implementation: browser (specifically Firefox)
Additional context
Browser versions tested:
Firefox: 115.0.3 - fails
Chrome: 115.0.5790.114 - works
Safari 16.4 - works
Looking at the implementation my best guess is that Firefox only triggers the implicit checked behavior when the event inherits from MouseEvent (as fireEvent.click uses) and not PointerEvent (as userEvent.click uses with v14+).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked CodeSandbox reproduction and inspect the userEvent.click entry point, especially its PointerEvent path, then compare it with fireEvent.click's MouseEvent behavior in Firefox. Add a regression test for clicking a radio label and verify that the radio becomes checked in Firefox without breaking behavior in other browsers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100