Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pointer Events check sometimes returns false positives #922

Closed
MattyBalaam opened this issue Apr 11, 2022 · 15 comments · Fixed by #991
Closed

Pointer Events check sometimes returns false positives #922

MattyBalaam opened this issue Apr 11, 2022 · 15 comments · Fixed by #991
Labels
bug Something isn't working released

Comments

@MattyBalaam
Copy link

MattyBalaam commented Apr 11, 2022

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

@MattyBalaam MattyBalaam added bug Something isn't working needs assessment This needs to be looked at by a team member labels Apr 11, 2022
@MattyBalaam MattyBalaam changed the title Pointer Events check sometimes returns false positives. Pointer Events check sometimes returns false positives Apr 11, 2022
@ph-fritsche
Copy link
Member

ph-fritsche commented Apr 11, 2022

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 the user.click with userEvent.click, i.e. starting a new "session", works, because it considers the pointer to be at document.body.

I think first of all we should improve the error message and report the target element as well as the element which has pointer-events: none.

Then we should probably not throw an error but just skip the events if the target was not explicitly mentioned in the API call, i.e. click(elX) should only throw if elX receives no pointer events. Removing the check for previous position might be a mistake though, because unhover(elX) should probably still throw.

@ph-fritsche ph-fritsche removed the needs assessment This needs to be looked at by a team member label Apr 11, 2022
@stefan2718
Copy link

For other users hitting this issue, I've worked around it by updating my config to ignore the hover events

const user = userEvent.setup({ skipHover: true });

@desmond-tuiyot
Copy link

desmond-tuiyot commented Jun 7, 2022

For other users hitting this issue, I've worked around it by updating my config to ignore the hover events

const user = userEvent.setup({ skipHover: true });

My userEvent import doesn't have any property like setup. How does this solution work exactly?
EDIT: seems like this was introduced in v14, and I'm still on v13.

@github-actions
Copy link

🎉 This issue has been resolved in version 14.2.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

@ph-fritsche
Copy link
Member

@all-contributors add @MattyBalaam bug

@allcontributors
Copy link
Contributor

@ph-fritsche

I've put up a pull request to add @MattyBalaam! 🎉

@rotimidokun
Copy link

I changed my approached based on @ph-fritsche first comment
from await user.click(element) to declaring element as variable and calling element.click()

works for me.

@EEBK99
Copy link

EEBK99 commented Dec 8, 2022

@rotimidokun please share your code or test case snippet.

@rotimidokun
Copy link

@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()

@ph-fritsche
Copy link
Member

This is not a good replacement for userEvent.click - see this post on why you should use the user-event Api.
If you use the latest version of user-event and have problems, please file an issue with a reproduction example.

@rotimidokun
Copy link

okay, thanks. @ph-fritsche

@quickEscape
Copy link

I still have the issue in 14.4.3

@Lokua
Copy link

Lokua commented Nov 15, 2023

I also have this issue in 14.5.1. Unfortunately I do not have capacity to add a repro right now.

@ffjdm
Copy link

ffjdm commented Jul 11, 2024

I have the issue in 16.0.0

@supuwoerc
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants