-
Notifications
You must be signed in to change notification settings - Fork 411
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: don't track clicks on disabled elements #2468
Conversation
Branch preview✅ Deploy successful! https://disabled_tracking--walletweb.review-wallet-web.5afe.dev |
ESLint Summary View Full Report
Report generated by eslint-plus-action |
trackEvent(trackData) | ||
const handleClick = (e: MouseEvent) => { | ||
// If clicked target is disabled, event.target will be trackEl | ||
if (e.target !== trackEl) { |
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.
What if a nested element intercepts the click? Will it always bubble up to trackEl
?
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.
Yes. It seems to work nicely in my tests, even with stopPropagation
on nested elements.
I'm converting this to a draft whilst I investigate this further. |
@katspaugh, @usame-algan, I've adjusted the approach to check whether child elements are disabled. Wdyt? |
What about the previous idea we discussed of passing a |
Whilst I tend to agree, it is hard to enforce. As we have the input ref, I don't see it as a workaround. |
LGTM I've checked the buttons in the list. |
What it solves
Resolves #2405
How this PR fixes it
Elements wrapped in
Track
now check whether thechildren
is targetted. If not, it means that the clickedtarget
is disabled and, as such, not tracked.How to test it
Click the following elements whilst disabled and observe no tracking event for them:
Checklist