Skip to content

Fix TypeError: href?.startsWith is not a function in profile raid dots - #388

Open
seer-by-sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/website-34-svg-link-error
Open

Fix TypeError: href?.startsWith is not a function in profile raid dots#388
seer-by-sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/website-34-svg-link-error

Conversation

@seer-by-sentry

Copy link
Copy Markdown

This PR addresses WEBSITE-34, a TypeError: href?.startsWith is not a function that occurred when clicking raid dots on a user's profile page (/profile/:destinyMembershipId).

Root Cause:
When a Next.js <Link> component was used inside an SVG element in src/components/__deprecated__/profile/raids/Dot.tsx, it rendered an SVG <a> element. Unlike HTML <a> elements where href is a string, an SVG <a> element's href property is an SVGAnimatedString object. The Next.js router's link interception logic, specifically href?.startsWith(), expected a string and thus threw a TypeError when encountering SVGAnimatedString.

Solution:

  1. Replaced Next.js <Link> with a native SVG <a> element: This ensures the href attribute behaves as expected for an SVG anchor.
  2. Implemented client-side navigation with useRouter().push(): An onClick handler was added to the <a> element. It calls e.preventDefault() to stop the default browser navigation and then uses router.push() to perform a client-side route change.
  3. Preserved modifier-key click behavior: The e.preventDefault() call is now conditional, allowing Ctrl/Cmd + click or middle-click to open the link in a new tab, mimicking standard browser behavior for links.
  4. Updated ref type: The useRef type was updated from HTMLAnchorElement to SVGAElement to correctly reflect the DOM element type.

Fixes WEBSITE-34

@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
raid-hub Error Error Jul 30, 2026 10:28am

Request Review

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.

0 participants