jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/380469 )

Change subject: Bug: Fix Link not capturing certain clicks
......................................................................


Bug: Fix Link not capturing certain clicks

When clicking on DOM elements inside the anchor element, the Link
component wouldn't capture the click and direct it to client side
navigation.

This is because it was using event.target internally, when that is the
originator of the event. Instead, we want to check the anchor, which is
the currentTarget instead, the element on the current phase of bubbling.

This patch fixes the problem and adds a comment.

The bug can be experienced by clicking on the Wordmark in the header,
where the link contains an SVG element and the event.target would end up
being a path element or something else.

Change-Id: I156d9c293ecae85c05af5d6c2112e1d6236c76c9
---
M src/common/components/link.tsx
1 file changed, 3 insertions(+), 1 deletion(-)

Approvals:
  Niedzielski: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/src/common/components/link.tsx b/src/common/components/link.tsx
index 92b580c..75ec31c 100644
--- a/src/common/components/link.tsx
+++ b/src/common/components/link.tsx
@@ -24,7 +24,9 @@
       href={href}
       onClick={event => {
         const origin = window.location.origin;
-        const link = event.target as HTMLAnchorElement;
+        // Use currentTarget as target may be other DOM elements inside the
+        // anchor element
+        const link = event.currentTarget as HTMLAnchorElement;
         // TODO: Move all the logic to check if an event should be captured to 
a
         // DOM utilities module and add unit tests
         if (

-- 
To view, visit https://gerrit.wikimedia.org/r/380469
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I156d9c293ecae85c05af5d6c2112e1d6236c76c9
Gerrit-PatchSet: 1
Gerrit-Project: marvin
Gerrit-Branch: master
Gerrit-Owner: Jhernandez <[email protected]>
Gerrit-Reviewer: Niedzielski <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to