Skip to content

fix: prevent nested anchor elements in NavigationItem tooltip#28659

Draft
claygeo wants to merge 1 commit intocalcom:mainfrom
claygeo:fix/nav-nested-anchor-clean
Draft

fix: prevent nested anchor elements in NavigationItem tooltip#28659
claygeo wants to merge 1 commit intocalcom:mainfrom
claygeo:fix/nav-nested-anchor-clean

Conversation

@claygeo
Copy link
Copy Markdown

@claygeo claygeo commented Mar 29, 2026

Fixes #27984. Wrap Link in a span so Radix Tooltip doesn't create nested anchor elements. 1 file, 2 lines. Replaces #28645 which had unrelated changes.

Radix Tooltip's asChild merges its trigger with the first child.
When the child is a Next.js Link (<a>), the result is nested <a>
elements. Wrap Link in a <span> to prevent this.

Fixes calcom#27984
@github-actions github-actions bot added the 🐛 bug Something isn't working label Mar 29, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

Copy link
Copy Markdown
Member

@romitg2 romitg2 left a comment

Choose a reason for hiding this comment

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

hey mind adding before/after image, maybe showing that console that error no longer appears, and ui is not affected.

@romitg2 romitg2 marked this pull request as draft March 29, 2026 17:07
@claygeo
Copy link
Copy Markdown
Author

claygeo commented Mar 29, 2026

@romitg2 Thanks for the review! Here are the before/after screenshots from the reproduction app (#27984).

Before (bug) — validateDOMNesting console error

Tooltip.Trigger asChild merges trigger props into <Link>, making the <Link> render as <a>. Any descendant anchor (like a badge) creates invalid nesting:

Before fix — console error

Console output:

Warning: validateDOMNesting: <a> cannot appear as a descendant of <a>.
  at a
  at NavigationItem (NavigationItem.tsx:206)
  at Tooltip (Tooltip.tsx:49) — TooltipPrimitive.Trigger asChild
  at NavigationItem (NavigationItem.tsx:205)

After (fix) — console clean

Wrapping <Link> in <span> gives Tooltip.Trigger a non-anchor element to attach to. The <a> is inside the span, no nesting:

After fix — console clean

DOM before:

<a data-state="closed">  <!-- Tooltip.Trigger asChild'd into Link -->
  Event Types
  <a href="...">3</a>  <!-- nested anchor = console error -->
</a>

DOM after:

<span data-state="closed" class="flex w-full">  <!-- Tooltip.Trigger → span -->
  <a href="...">  <!-- Link, not nested in another <a> -->
    Event Types
    <a href="...">3</a>  <!-- OK: nested in span, not in <a> -->
  </a>
</span>

Visual layout is identical — both sections show the same nav items. Only the nesting structure changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working size/XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NavigationItem renders nested <a> elements when wrapped in Tooltip

2 participants