Skip to content

Conversation

@abhi-agg
Copy link
Contributor

@abhi-agg abhi-agg commented Mar 4, 2024

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1882747

#154 had introduced Glean's manual click event recording at some place.
We are using Glean's automatic click event recording at all places now.

@abhi-agg abhi-agg requested a review from rosahbruno March 4, 2024 21:21
data-glean-label='Sun Theme'
>
<circle cx='11.9998' cy='11.9998' r='5.75375' fill='currentColor' />
<circle cx='11.9998' cy='11.9998' r='5.75375' fill='currentColor' data-glean-label='Sun Theme'/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried, instead, setting the label here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I have. The click events never get fired on <button> element that you linked.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's quite a bit odd that we need to tag all the sub-elements that make a React element: this is not going to be possible when using other things we don't own. I wonder if the problem lies elsewhere.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is weird that events aren't fired on the button. I agree that if we have to tag elements really far down in the DOM tree it might get really hard for users to figure out how to tag their elements.

I also wonder if there is someway we can fix our side so that we can get the button element clicks to register

Copy link
Contributor Author

@abhi-agg abhi-agg Mar 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are capturing clicks only on those elements that have data-glean-* attributes set.

One approach that @badboy suggested is to add "click" event listeners for all those elements that have data-glean-* attributes set (instead of a general click listener on the entire document and then filtering which ones have these attributes set) in the document and using the event bubbling to capture events on the parent of the outermost svg element.

This might work but I will have to test it to say for sure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the specific issue above, I was able to get the button click working by setting pointerEvents: 'none' on the SVG elements instead.

It would be nice if we could somehow walk the tree of elements to check for the data-glean-label rather than having to rely on that one specific element having it. Event bubbling looks like what we may need, I am going to look into any ways to see if we can walk the DOM tree at all

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this behavior only happening with SVGs? Did we try this with other types of elements and see if we are running into the same issues? I think if this works generally across the board and we have to include some caveats for SVGs or tell the users to just use the built-in click event that wouldn't be a terrible UX.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the specific issue above, I was able to get the button click working by setting pointerEvents: 'none' on the SVG elements instead.

I think this is the right path: let's not over-tweak this for this specific use-case, but rather just add the pointerEvents properties to the icons we have committed in tree.

@abhi-agg abhi-agg requested a review from Dexterp37 March 5, 2024 12:43
Copy link
Contributor

@rosahbruno rosahbruno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+wc

If we make the changes in the thread to just use pointer-events, that should be good for now. We can callout in our docs that there are certain elements where this may be an issue, like SVGs.

@abhi-agg abhi-agg force-pushed the glean-click-events branch from d0adb53 to c6e74c8 Compare March 11, 2024 09:25
@abhi-agg
Copy link
Contributor Author

abhi-agg commented Mar 11, 2024

@rosahbruno Thanks a lot for your review.

I made the changes pertaining to pointer-events=none. I am merging this change to move ahead with DPV deployment. If you feel that there is still something that needs to be changed, please feel free to let me know and I will create a followup PR 👍🏾

@abhi-agg abhi-agg merged commit bab1ebb into mozilla:main Mar 11, 2024
@abhi-agg abhi-agg deleted the glean-click-events branch March 11, 2024 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants