-
Notifications
You must be signed in to change notification settings - Fork 244
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
fix(click): throw an error when trying to click with pointer-events set to none #647
fix(click): throw an error when trying to click with pointer-events set to none #647
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 3ae2693:
|
Codecov Report
@@ Coverage Diff @@
## master #647 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 50 50
Lines 918 922 +4
Branches 363 363
=========================================
+ Hits 918 922 +4
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 for your contribution. ❤️
We should probably throw the same error on |
Co-authored-by: Philipp Fritsche <ph.fritsche@gmail.com>
@ph-fritsche I actually considered doing it for hover too, but wasn't sure if out of scope for this PR. Given that hovers usually provide side-effects and aren't usually explicit actions, I'm not sure if we should error when hovering over something that's disabled. FWIW, I find that Cypress has very sensible assertions they make on their commands to simulate user behaviour (such as, failing when trying to click a non-clickable element) and this is the inspiration I used for this PR. Interestingly, What do you think? I'd be happy to add it to this PR, or to propose it as a future (or separate) improvement. |
@vicrep I think users calling |
@ph-fritsche makes sense, I've added the same behaviour to hover/un-hover 👍 Please let me know if there's anything else you need from me to merge this :) |
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 :)
🎉 This PR is included in version 13.1.3 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
@all-contributors add @vicrep code |
I've put up a pull request to add @vicrep! 🎉 |
What:
As discussed here: #639 (comment) , the new behaviour which was recently added to prevent clicks from being emitted when pointer-events are set to
none
had the side-effect of silently no-oping when this was the case, making it:I've added this behaviour to both the click and double-click.
Why:
This change follows the paradigm that testing-library provides for selectors, where
getBy
will throw an error if the element doesn't exist. Similarly, trying to click something which is not clickable should also throw an error, as this is an action which cannot be performed by a real user. Some other testing frameworks, such as Cypress, follow similar behaviour of failing when trying to click non-clickable elements.This also makes dealing with animating elements which might set their pointer events to
none
while animating way more straightforward, using thewaitFor
utility:Checklist: