Repository navigation
fix(Link): maxLines truncates inside a line narrower than the link - #9059
Conversation
Link renders its root inline-flex with no width cap, so with maxLines > 0 in a constrained line (a one-line p in a grid column) the root grew to its whole text, its Text never overflowed its own box, no ellipsis drew and the parent clipped the text. With maxLines > 0 the root now stops at its container (max-width 100%, min-width 0), so Text truncates as component:Text FR4 says, in the anchor and the button form (component:Link FR6). A story and a Chromium spec show both forms stop at the line and draw the ellipsis. ManoharPaturi's #6038 works on the related ancestor-clamp case.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewComponent Size
Sizes are gzip. Import counts the JavaScript the import loads eagerly; CSS counts the package stylesheet rules referenced by the modules it can load from its own package, lazily loaded ones included. Bundle Size SummaryGzip figures measure each package's entry file, not the code an import pulls in.
Accessibility AuditStatus: The accessibility audit did not run on this pull request. It runs after merges to Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
The maxLines fix does what it says (a Link now stops at its container and its label ends in an ellipsis), but approval waits on two things. An engineering owner needs to decide the new component:Link FR6 wording ("with maxLines above 0 it stops at its container…") and its verification row by commenting /approve-spec <full head SHA> on this pull request; the author may record it too, as an engineering owner. Separately, Link.truncation.chromium.spec.ts never runs, because playwright.config.ts only collects *.a11y.chromium.spec.ts: please rename it to Link.truncation.a11y.chromium.spec.ts and update the FR6 verification row and verified_by to match.
[Automated review]
| @@ -0,0 +1,58 @@ | |||
| // Copyright (c) Meta Platforms, Inc. and affiliates. | |||
| // @pr-a11y scope ^(packages/core/src/Link/|packages/core/src/Text/|apps/storybook/stories/Link\.stories) | |||
There was a problem hiding this comment.
Playwright never collects this file: playwright.config.ts only matches packages/*/src/**/*.a11y.chromium.spec.ts and *.a11y.browser.spec.ts, and both the PR accessibility job and the release contract shards list specs through that config. Listing this file with --config playwright.config.ts --project chromium prints "No tests found". Renaming it to Link.truncation.a11y.chromium.spec.ts (and updating the FR6 verification row and verified_by) puts it in those runs; measured on this story, the base's 386 px root would fail its first assertion and this head passes all three.
There was a problem hiding this comment.
The maxLines fix works (a Link now stops at its container and its label ends in an ellipsis), but approval waits on an engineering owner's decision on the new component:Link FR6 wording ("with maxLines above 0 it stops at its container…") and its verification row, recorded by commenting /approve-spec <full head SHA> on this pull request; the author may record it as an engineering owner. Two fixes are needed either way:
- Rename
Link.truncation.chromium.spec.tstoLink.truncation.a11y.chromium.spec.tsand update the FR6 verification row andverified_by, sinceplaywright.config.tsonly collects*.a11y.chromium.spec.ts. - Start the changeset body with
[fix]and add a contributor handle on its own line, sopnpm check:changesetsand thelintcheck pass.
[Automated review]
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| Link: `maxLines` now truncates when the link sits in a line narrower than its text. The link, as an anchor or a button, stops at its container and its label draws an ellipsis, instead of growing to its whole text and being clipped with no ellipsis. |
There was a problem hiding this comment.
pnpm check:changesets rejects this entry, which is why lint fails: the body must start with a category tag and credit a contributor (docs/specs/AST-017/spec.md FR7: "corrections use [fix]"). For example, start it with [fix] Link: maxLines now truncates… and add your handle on its own line after it, or regenerate it with pnpm changeset:new.
There was a problem hiding this comment.
The maxLines fix works and the changeset now passes check:changesets, but approval still waits on an engineering owner's decision on the new component:Link FR6 wording ("with maxLines above 0 it stops at its container…") and its verification row, recorded by commenting /approve-spec <full head SHA> on this pull request; the author may record it as an engineering owner. One fix is needed either way:
- Rename
Link.truncation.chromium.spec.tstoLink.truncation.a11y.chromium.spec.tsand update the FR6 verification row andverified_by, sinceplaywright.config.tsonly collects*.a11y.chromium.spec.tsand the file currently runs in no lane.
[Automated review]
…mium lane collects it CodeBunny on #9059: playwright.config.ts collects only *.a11y.chromium.spec.ts under packages, so Link.truncation.chromium.spec.ts ran in no lane. Renamed; the FR6 verification row and verified_by name it.
There was a problem hiding this comment.
The maxLines fix works: a Link with maxLines above 0 now stops at its container and its label ends in an ellipsis, and the renamed Chromium spec is now collected and passes. Approval waits only on an engineering owner's decision on the new component:Link FR6 wording ("with maxLines above 0 it stops at its container…") and its verification row, recorded by commenting /approve-spec <full head SHA> on this pull request; the author may record it as an engineering owner. When deciding, note that the clause reads broader than the fix: a Link that follows other text in a clipping line is still capped at the full container width and shows no ellipsis of its own, as before.
[Automated review]
|
/approve-spec f35a7c3 |
There was a problem hiding this comment.
Approval recommended: with maxLines above 0, Link now stops at its container in its anchor, disabled and button forms, so its label ends in an ellipsis, and the regression spec over the new story passes on this head and fails on the base. The reworded FR6 clause carries an engineering owner's approval for this exact head, and no defect or evidence gap remains.
[Automated review]
What changes for people
A Link set to one line (
maxLines={1}) inside a line narrower than its text now shows "…" where the text is cut. Today, as an anchor or as a button (onClick), the link grows to its whole text, its label never overflows, and the surrounding line clips it mid-word with no ellipsis, so people can't tell the text continues, and the truncation tooltip never arms.Why it is a fix
component:LinkFR6 passesmaxLinesto the link's Text.component:TextFR4 saysmaxLines={1}clips one line with an ellipsis.The Link root,
inline-flexwith no width cap, kept that from happening inside a constrained line.Change
Link.tsx: withmaxLinesabove 0, the root stops at its container (max-width: 100%,min-width: 0) in the anchor, disabled and button forms. Nothing changes atmaxLines={0}(the default).Link.spec.mdFR6 states it, and the FR6 verification row names the new spec.Core/Link › Truncated In Constrained Line: a 220 px column with an anchor and a button Link, eachmaxLines={1}.Link.truncation.a11y.chromium.spec.ts: in real Chromium, each form's root fits the line, its label overflows, andtext-overflowisellipsis.Spec authority
The FR6 clause is a consistency edit of the current record: FR6 already passes
maxLinesto the link's Text, andcomponent:TextFR4 definesmaxLines={1}as one clipped line with an ellipsis. The clause states the layout that makes FR6'smaxLinestake effect (the root stops at its container); it adds no behavior choice.Related work
ManoharPaturi's #6038 works on a related truncation case: a Link inside an ancestor Text with
maxLines. That one depends on an open spec decision about the root box, while this PR covers only the Link's ownmaxLines. Both touch Link's root styles, so whichever lands second rebases.Not in this PR
Passing a tooltip or touch-trigger option from Link to its Text would be new public API, so it goes through a spec decision first.
Evidence
pnpm vitest run packages/core/src/Link: 117 passed.pnpm check:knowledge: clean.LOC
+106 / −2 across 5 files: 11 lines of source, plus the story, spec, record and changeset.