Skip to content

Navigation Menu

Sign in
Sign up

fix(core): render plain Link anchors inline so an ancestor Text clamp can truncate them - #6090

Open
parinith-web wants to merge 5 commits into
facebook:main from
parinith-web:fix-link-anchor-clamp-block-focus
Open

fix(core): render plain Link anchors inline so an ancestor Text clamp can truncate them #6090
parinith-web wants to merge 5 commits into
facebook:main from
parinith-web:fix-link-anchor-clamp-block-focus

Conversation

@parinith-web

@parinith-web parinith-web commented Sep 6, 2026

Copy link
Copy Markdown

This PR is the same fix as #6038 (opened by @ManoharPaturi), plus one
additional commit addressing the latest review comment on that thread.
Opening this directly against main at @ManoharPaturi's suggestion /
per our discussion.

Fixes #6021

Summary

A plain <Text maxLines={2}><Link>...</Link></Text> silently did not truncate:
the anchor was display: inline-flex, and an inline-flex box establishes its
own formatting context that an ancestor -webkit-line-clamp cannot reach.

This changes the plain anchor to display: inline so it participates in the
surrounding line boxes and an ancestor clamp truncates it normally. The flex
layout is preserved wherever it's load-bearing:

  • external links (isExternalLink + anchor form) stay inline-flex
  • the button-rendered form stays inline-flex
  • display="block" and self-clamping (maxLines > 0) Links stay inline-flex
    so their keyboard focus outline still paints (an inline anchor around a
    block-level child computes a focus outline but paints nothing in Chromium)
  • Links composing a block-level child directly (e.g. an HStack + Icon) can
    now opt in via a new hasBlockChild prop, for the same focus-visibility
    reason — added as an explicit prop rather than introspecting children,
    since this repo's no-react-introspection ESLint rule disallows
    Children.toArray/isValidElement for that kind of parent-child coupling

Docs updated in all three variants (EN/zh/dense) for Link and Text
covering when ancestor-clamp truncation will/won't reach a Link.

Tests

  • plain anchor → inline, not inline-flex
  • external-link anchor → inline-flex
  • button-rendered form → inline-flex
  • display="block"inline-flex
  • self-clamping (maxLines > 0) → inline-flex
  • hasBlockChild (HStack + Icon composition) → inline-flex

Testing

  • vitest run packages/core/src/Link packages/core/src/Text — 256 passed
  • tsc --noEmit (core) clean
  • eslint clean
  • check:sync clean
  • check:changesets clean

Co-authored-by: ManoharPaturi 186662190+ManoharPaturi@users.noreply.github.com

ManoharPaturi and others added 5 commits September 4, 2026 23:56
The displayDeclarationsFor helper added in facebook#6038 matched an element's
classList against raw selector text via String.includes, which is a
substring check on hashed atomic class names (e.g. StyleX's x1a2b3c
style classes). A shorter class name can be a substring of an
unrelated longer one, so the check can both false-positive and
false-negative depending on what else StyleX has generated for the
test run.
Rewrite it to walk the real CSSOM: parse each CSSStyleRule's
selectorText into class tokens, compare those tokens against the
element's classList by exact match, and read the declaration via
rule.style.getPropertyValue('display') instead of a body-text regex.
Also descends into grouping rules (e.g. @media) so nested
declarations aren't missed.
Flagged by Copilot review on facebook#6038:
facebook#6038 (review)
All 63 Link tests and 189 Text tests still pass; tsc --noEmit is clean.

vercel Bot commented Sep 6, 2026
edited
Loading

Copy link
Copy Markdown

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

Project Deployment Actions Updated
astryx Ready Ready Preview Sep 6, 2026 6:22pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 6, 2026
@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge needs:design-review Affects visuals — Design should review labels Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@cixzhang cixzhang Awaiting requested review from cixzhang cixzhang is a code owner
@imdreamrunner imdreamrunner Awaiting requested review from imdreamrunner imdreamrunner is a code owner
@josephfarina josephfarina Awaiting requested review from josephfarina josephfarina is a code owner
@cvkxx cvkxx Awaiting requested review from cvkxx
@ernestt ernestt Awaiting requested review from ernestt
@kentonquatman kentonquatman Awaiting requested review from kentonquatman
@rubyycheung rubyycheung Awaiting requested review from rubyycheung

Assignees

No one assigned

Labels

CLA Signed This label is managed by the Meta Open Source bot. community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge needs:design-review Affects visuals — Design should review

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Link's inline-flex anchor silently defeats an ancestor Text maxLines clamp

AltStyle によって変換されたページ (->オリジナル) /