testing-library / testing-library/user-event

Clicking on a label element of a checkbox does not trigger checkbox

Open
#1,230 1 comment 6 reactions 0 assignees View on GitHub

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
  1. Render <label><span>label</span><input type="checkbox" /></label>
  2. Find label element
  3. Click on label element
  4. 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

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.