user-event: Pointer Events check sometimes returns false positives
Reproduction example
https://codesandbox.io/s/exciting-fire-b1ibfk?file=/src/App.test.js
Prerequisites
If you run a userEvent.click on an element which then has pointer-events: none added after the interaction, then the next userEvent.clickon a different element thinks the element inherits pointer-events: none
Expected behavior
userEvent.click should not throw a warning.
Actual behavior
Error thrown “Unable to perform pointer interaction as the element has or inherits pointer-events set to “none”.”
User-event version
14.0.4
Environment
See sandbox, which is using React 18. I also see the issue in React 17 locally.
Additional context
No response
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 13
- Comments: 17 (4 by maintainers)
I still have the issue in 14.4.3
For other users hitting this issue, I’ve worked around it by updating my config to ignore the hover events
@EEBK99 i don’t remember where i wrote that code, but it looks something like this
const element = getByRole('button', {name: "test"})Instead of
await userEvent.click(element)I used
element.click()Thanks for the report. ❤️
Looks like this is not a false-positive for the other element. The implicit movement of the cursor out of the previously hovered element (that now has
pointer-events: none) triggers the error. Replacing theuser.clickwithuserEvent.click, i.e. starting a new “session”, works, because it considers the pointer to be atdocument.body.I think first of all we should improve the error message and report the
targetelement as well as the element which haspointer-events: none.Then we should probably not throw an error but just skip the events if the
targetwas not explicitly mentioned in the API call, i.e.click(elX)should only throw ifelXreceives no pointer events. Removing the check for previous position might be a mistake though, becauseunhover(elX)should probably still throw.I also have this issue in 14.5.1. Unfortunately I do not have capacity to add a repro right now.
🎉 This issue has been resolved in version 14.2.6 🎉
The release is available on:
Your semantic-release bot 📦🚀
We still experience this issue even with the
pointerEventsCheck: PointerEventsCheckLevel.EachTriggerin place!@ph-fritsche
I’ve put up a pull request to add @MattyBalaam! 🎉