Skip to content

fix: use components.Link for inline text links to prevent nested anchors#697

Open
albertodainotti wants to merge 1 commit intoNotionX:masterfrom
InetIntel:fix-inline-text-nested-anchors
Open

fix: use components.Link for inline text links to prevent nested anchors#697
albertodainotti wants to merge 1 commit intoNotionX:masterfrom
InetIntel:fix-inline-text-nested-anchors

Conversation

@albertodainotti
Copy link
Contributor

Problem

When components.PageLink is overridden (e.g., to render a custom <div> container instead of <a>), the inline text decorators in text.tsx create nested DOM issues. Specifically, the 'p' (page mention), '‣' (cross-workspace link), and 'a' (internal URL) decorators all use components.PageLink, which means:

  1. Inline page mentions inside a PageLink-wrapped title cell create a PageLink inside a PageLink (nested containers)
  2. If the outer PageLink renders as <a>, this produces invalid <a> inside <a> HTML, causing React hydration errors

These inline text links are semantically different from block-level page links — they appear within text content and should behave as simple navigation links, not as page-level containers.

Fix

Changed the three inline text decorators from components.PageLink to components.Link:

Decorator Purpose Before After
'p' Inline page mention (@page Name) components.PageLink components.Link
'‣' Cross-workspace page link components.PageLink components.Link
'a' Internal URL recognized as page link components.PageLink components.Link

This preserves the existing behavior for custom Link overrides while preventing nesting issues with custom PageLink overrides.

Files Changed

  • packages/react-notion-x/src/components/text.tsx — 6 lines changed (3 opening tags + 3 closing tags)

The 'p' (page mention), '‣' (cross-workspace), and 'a' (internal URL)
text decorators in text.tsx used components.PageLink to wrap inline text
content. Since these are inline text hyperlinks (not block-level page
references), children can contain other link decorators that render as
<a> tags via components.Link, producing invalid nested <a> elements
and causing React SSR hydration errors.

Switch all three decorators to use components.Link instead, which is
semantically correct: inline text hyperlinks should be handled by the
Link component regardless of whether they point internally or externally.
components.PageLink is reserved for block-level page references (alias
blocks, collection cards, search results, breadcrumbs).
@vercel
Copy link

vercel bot commented Mar 11, 2026

@albertodainotti is attempting to deploy a commit to the Saasify Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant