testing-library / testing-library/user-event
Clicking on a label element of a checkbox does not trigger checkbox
Open
Nobody has claimed this yet.
bug
- Dominant language
- TypeScript
- Stars
- 2.3k
- Forks
- 258
- PR merge metrics
- No merged PRs in 30d
Description
Reproduction example
https://codesandbox.io/p/devbox/elated-gould-h5tv93
Prerequisites
- Render
<label><span>label</span><input type="checkbox" /></label> - Find label element
- Click on label element
- Watch whether checkbox checked
Expected behavior
The checkbox should be checked.
Actual behavior
The checkbox is still unchecked.
User-event version
14.5.2
Environment
Testing Library framework:
JS framework:
Test environment:
DOM implementation:
Additional context
No response
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
No source file or test is named. Reproduce the nested label and checkbox case in the linked CodeSandbox, then trace the label-click handling in user-event against the stated React, jsdom, and user-event versions. Done means clicking the label checks the checkbox and the behavior is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100