testing-library / testing-library/user-event
hover then click children lost target
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/p/devbox/react-jest-test-4yx2wr?file=/src/App.js
Prerequisites
- An element contains a child element, and the child element is only displayed when mouse hover
- test hover the element, then click child element
Expected behavior
child element displayed and click event is triggered
Actual behavior
child element hidden, and click event is not triggered
User-event version
14.5.2
Environment
Testing Library framework: @testing-library/react@14.1.2
JS framework: react@18.0.2
Test environment:
DOM implementation:
Additional context
I debugged the code and found that the pointer event compared prevTarget and currTarget. When they are not equal, the mouseLeave event will be triggered, which will cause the child elements to be hidden and the target to be lost in subsequent events.
Maybe we can determine whether to trigger the mouseLeave event based on the node level, which will be closer to the browser's implementation.
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 trace the pointer-event handling that compares the previous and current targets. Check the existing interaction tests around hover and click behavior, then verify that hovering reveals the child and clicking it triggers the event without hiding the child first.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100