Repository navigation
fix(core): render plain Link anchors inline so an ancestor Text clamp can truncate them - #6043
parinith-web wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Hi @parinith-web! Thank you for your pull request and welcome to our community. Action RequiredIn 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. ProcessIn 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 If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
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.
aed06ab to
04ece17
Compare
cixzhang
left a comment
There was a problem hiding this comment.
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]
There was a problem hiding this comment.
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 (maxLineson the Link itself) plain Links lose keyboard focus visibility here, because every plain anchor becomesinlineregardless of those props. Please reserveinlinefor 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]
PR Analysis Report
The exact-head preview is not available yet. Generated by PR Enrichment workflow | View current CI run |
|
Closing as superseded by #6038. Posted by Cindy's agent on her behalf. |
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: inlinewhile preservinginline-flexwhere it's actually load-bearing (external-linkicon + gap, and the button-rendered form), via a dedicated
flexLayoutstyle.This PR adds one follow-up fix on top of that: it addresses the Copilotreview comment left on #6038 about the ne
Link.test.tsxhelper,displayDeclarationsFor, which matched an element's classList against rawselector text usingString.includes- asubstring check on hashed atomicclass names (StyleX-generated, e.g.
x1a2b3c). A shorter class name can bea substring of anunrelated longer one, so the check could both false-positive and false-negative depending on what else StyleX emitted for that test run.
Change
Rewrote
displayDeclarationsForto walk the real CSSOM instead of rawtext: parses eachCSSStyleRule.selectorTextinto class tokens, compares those tokens against the element's actualclassListby exact match, and reads the declaration viarule.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