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
Prevent element to be clicked if pointer events are disabled for the element #631
Prevent element to be clicked if pointer events are disabled for the element #631
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit e9c3327:
|
Codecov Report
@@ Coverage Diff @@
## master #631 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 48 49 +1
Lines 891 911 +20
Branches 351 361 +10
=========================================
+ Hits 891 911 +20
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for taking the time to contribute ❤️
Could you rename the isElementClickable
to hasPointerEvents
and add it to dblClick
, hover
and unhover
too?
We should also exclude the pointerEvents in selectOptionsBase
.
Sure. I'll update PR with your suggestions |
Co-authored-by: Philipp Fritsche <ph.fritsche@gmail.com>
I'm not sure if I understood use case here, As once I merged this suggestion, my existing test cases started failing that I added to validate that we should return and should not fire any other events. Please advise @ph-fritsche |
Co-authored-by: Philipp Fritsche <ph.fritsche@gmail.com>
Have a look at MohitPopli#1 |
Suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me now. Thanks a lot for your work on this 😃
I will have another look later and merge it if nothing leaps out at me then. 🚀
🎉 This PR is included in version 13.1.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
@all-contributors add @MohitPopli bug, code, test |
I've put up a pull request to add @MohitPopli! 🎉 |
Hello, I use reactstrap and test my components with RTL and userEvent and since this feature, I encounter an error when I want to test my dropdown. I made a codesandbox to reproduce my error : https://codesandbox.io/s/dropdown-userevent-mo7h1?file=/src/MyDropdown.spec.tsx It looks like the click is not triggered on my menu item. To make it work, I found a workaround by setting the pointer-events style to |
@rbung I tried to triage the issue on my system and everything seems to work fine with me without having to set I have used below queries used to click on dropdown and then menu item,
Playground link: https://testing-playground.com/gist/1e9acc0b446eba5d32d611b0475997b4/bd9fec04e960bf99a17138efda8327c03003b149 Let me know if you have any questions. |
@rbung Your problem is described in #639 (comment) Update await waitFor(() => userEvent.click(screen.getByRole("menuitem"))) |
What: Before firing click event on element, added check to validate if element is clickable.
Why: Though we trust browser to do it's job perfectly, but still if element have pointer-events disabled then it should not propagate any events or callbacks.
How: Created a utility function to check for
pointer-events
css value, if it's set tonone
then we should not click the element and return.Checklist:
Closes #630