Skip to content

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

Closed
parinith-web wants to merge 3 commits into
meta:mainfrom
parinith-web:fix-link-anchor-clamp
Closed

parinith-web wants to merge 3 commits into
meta:mainfrom
parinith-web:fix-link-anchor-clamp

Conversation

@parinith-web

Copy link
Copy Markdown
Contributor

Fixes #6021

Summary

Builds on @ManoharPaturi's fix in #6038, which correctly identified and fixed the root cause: Link's plain anchor was display: inline-flex, whichestablishes its own formatting context that an ancestor -webkit-line-clamp (from <Text maxLines>) cannot reach into — so <Text maxLines={2}><Link>…</Link></Text> silently failed to truncate.

His fix changes the plain anchor to display: inline while preserving inline-flex where it's actually load-bearing (external-link
icon + gap, and the button-rendered form), via a dedicated flexLayout style.

This PR adds one follow-up fix on top of that: it addresses the Copilotreview comment left on #6038 about the neLink.test.tsx helper,displayDeclarationsFor, which matched an element's classList against rawselector text using String.includes - a
substring check on hashed atomicclass names (StyleX-generated, e.g. x1a2b3c). A shorter class name can bea substring of an
unrelated longer one, so the check could both false-positive and false-negative depending on what else StyleX emitted for that test run.

Change

Rewrote displayDeclarationsFor to walk the real CSSOM instead of rawtext: parses each CSSStyleRule.selectorText into class tokens, compares those tokens against the element's actual classList by exact match, and reads the declaration via rule.style.getPropertyValue('display') rather than a body-text regex. Also descends into grouping rules (e.g. @media) so nested declarations aren't missed.

Testing

  • vitest run packages/core/src/Link packages/core/src/Text — all passing (Link: 39, useLinkComponent: 11, useLinkify: 13, Text: 32, plus TextArea/TextInput which depend on Text — 252 total)
  • tsc --noEmit (core) — clean

@vercel

vercel Bot commented Sep 4, 2026 •

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 4, 2026 7:37pm UTC

Request Review

@meta-cla

meta-cla Bot commented Sep 4, 2026

Copy link
Copy Markdown

Hi @parinith-web!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@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 4, 2026
The displayDeclarationsFor helper added in meta#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 meta#6038:
meta#6038 (review)

All 63 Link tests and 189 Text tests still pass; tsc --noEmit is clean.

@cixzhang cixzhang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Existing block and self-clamped Links lose keyboard focus visibility in this change. Please preserve their focusable box while keeping only unclamped plain anchors inline.

[Reviewed by Robohands]

@ManoharPaturi

Copy link
Copy Markdown
Contributor

Folded into #6038 (commit 1abf92c, authorship preserved) — thanks again for the cleaner helper! Closing this out; maintainers only need to look at the single PR now.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the focused fix and the cleaner CSSOM test helper — the plain-anchor inline change is the right shape for letting an ancestor Text maxLines clamp truncate a Link, while keeping flex for the external-icon and button forms.

This PR should close as superseded rather than be revised or merged separately: its work has been folded into the consolidated PR with authorship preserved, both PRs change the same files and changeset, and that PR has since moved ahead — including on the focus cases below. Keeping a single review target avoids duplicate review and a conflicting changeset.

Two findings from this head, for the record on the consolidated PR:

  • Existing block (display="block") and self-clamped (maxLines on the Link itself) plain Links lose keyboard focus visibility here, because every plain anchor becomes inline regardless of those props. Please reserve inline for unclamped plain anchors and preserve a focusable box for Links that establish their own box.
  • There is no updated Storybook clamp case or before/after screenshots, which the repository asks for on visual changes; the declaration-level tests alone don't show rendered truncation or focus painting. The CSSOM helper should also match full selector applicability rather than any single class token, so the tests can't false-pass.

[Automated review]

@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

PR Analysis Report

Current run: The current CI run concluded failure. Current analysis is unavailable.

The exact-head preview is not available yet.


Generated by PR Enrichment workflow | View current CI run

@cixzhang

Copy link
Copy Markdown
Contributor

Closing as superseded by #6038. Posted by Cindy's agent on her behalf.

@cixzhang cixzhang closed this Oct 28, 2026
@github-actions
github-actions Bot deleted the fix-link-anchor-clamp branch October 29, 2026 12:10

This branch was successfully deployed

1 active deployment
Preview — 04ece17a Deployed Sep 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

Development

Successfully merging this pull request may close these issues.

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

3 participants