You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[EuiCard] title Prop Causing onClick to Trigger Twice When Clicked #6545
The title prop on EuiCard is causing the onClick method to trigger twice when the title is clicked. It appears that this only happens when a React Node is passed into title instead of a string.
Steps to Reproduce:
View the CodeSandbox link below and make sure the console is open
Click on the title text ('This is a title') and notice two console.log statements for each time the title is clicked
Click on the card body (not the title text) and notice that there's only one console.log statement for each time the body is clicked
Here's what's happening: because of the nested <span> being passed the title prop, the e.target in the above code is now the span, which is no longer equal to the link.
What we need to do: we need to add another conditional check to the if statement to ensure the link does not containe.target.
We should also add a unit test for this behavior to confirm that onClick was not called twice after the fix.
Activity
cee-chen commentedon Jan 24, 2023
Here's the source code that prevents the double onClick trigger:
eui/src/components/card/card.tsx
Lines 195 to 199 in d25437c
Here's what's happening: because of the nested
<span>being passed thetitleprop, thee.targetin the above code is now thespan, which is no longer equal to thelink.What we need to do: we need to add another conditional check to the if statement to ensure the
linkdoes not containe.target.We should also add a unit test for this behavior to confirm that
onClickwas not called twice after the fix.Jittojoyes98 commentedon Jan 25, 2023
Hey i would like to fix this issue