Skip to content
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: ButtonLink onClick handler #12935

Merged
merged 4 commits into from
May 18, 2024
Merged

fix: ButtonLink onClick handler #12935

merged 4 commits into from
May 18, 2024

Conversation

nhsz
Copy link
Member

@nhsz nhsz commented May 8, 2024

This PR updates the ButtonLink component to handle custom onClick events and override its behavior when needed. Fixes the issue of /wallets/find-wallet/ Visit website CTA not being tracking the event when clicked.

Testing

  • Go to /wallets/find-wallet/ now the Visit website button should be triggering the custom handleWalletWebsiteClick event handler
  • Go to any other page like /community/ to check that the ButtonLink component is still working as expected for other cases
Screen Shot 2024-05-08 at 17 06 47

Preview

https://deploy-preview-12935--ethereumorg.netlify.app/wallets/find-wallet

Copy link

netlify bot commented May 8, 2024

Deploy Preview for ethereumorg ready!

Name Link
🔨 Latest commit 82e3280
🔍 Latest deploy log https://app.netlify.com/sites/ethereumorg/deploys/663e80445638220008be92dc
😎 Deploy Preview https://deploy-preview-12935--ethereumorg.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
7 paths audited
Performance: 52 (🔴 down 4 from production)
Accessibility: 92 (no change from production)
Best Practices: 94 (🔴 down 4 from production)
SEO: 95 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

Comment on lines 12 to 14
customEventOptions,
onClick,
...props
Copy link
Member

Choose a reason for hiding this comment

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

Hm.. this is a little confusing since we're accepting an onClick, which could override the click handler per below, but we also have customEventOptions which wouldn't be used if onClick is provided...

@nhsz If we need to accept onClick here, should we merge it into the handleClick() function below? ie

const handleClick = () => {
  customEventOptions && trackCustomEvent(customEventOptions)
  onClick()
}

Copy link
Member

Choose a reason for hiding this comment

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

@nhsz @wackerow the underlying Button component already handles this logic. So I'd say, let's get rid of the onClick handler from this component completely and rely on the logic set in the button component. Otherwise, we are (and we were) duplicating this logic.

Comment on lines 12 to 14
customEventOptions,
onClick,
...props
Copy link
Member

Choose a reason for hiding this comment

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

@nhsz @wackerow the underlying Button component already handles this logic. So I'd say, let's get rid of the onClick handler from this component completely and rely on the logic set in the button component. Otherwise, we are (and we were) duplicating this logic.

@nhsz nhsz force-pushed the fix-buttonlink-onclick branch from 5f91ead to b55dc25 Compare May 10, 2024 16:32
@nhsz nhsz requested review from pettinarip and wackerow May 10, 2024 16:33
@nhsz nhsz merged commit f09e59c into dev May 18, 2024
10 checks passed
@nhsz nhsz deleted the fix-buttonlink-onclick branch May 18, 2024 21:16
This was referenced May 22, 2024
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