Skip to content

fix(Link): maxLines truncates inside a line narrower than the link - #9059

Merged
cixzhang merged 4 commits into
mainfrom
fix/link-maxlines-cap
Oct 31, 2026
Merged

cixzhang merged 4 commits into
mainfrom
fix/link-maxlines-cap

Conversation

@cixzhang

@cixzhang cixzhang commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

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:Link FR6 passes maxLines to the link's Text.
  • component:Text FR4 says maxLines={1} clips one line with an ellipsis.

The Link root, inline-flex with no width cap, kept that from happening inside a constrained line.

Change

  • Link.tsx: with maxLines above 0, the root stops at its container (max-width: 100%, min-width: 0) in the anchor, disabled and button forms. Nothing changes at maxLines={0} (the default).
  • Link.spec.md FR6 states it, and the FR6 verification row names the new spec.
  • Story Core/Link › Truncated In Constrained Line: a 220 px column with an anchor and a button Link, each maxLines={1}.
  • Link.truncation.a11y.chromium.spec.ts: in real Chromium, each form's root fits the line, its label overflows, and text-overflow is ellipsis.
  • Changeset: patch.

Spec authority

The FR6 clause is a consistency edit of the current record: FR6 already passes maxLines to the link's Text, and component:Text FR4 defines maxLines={1} as one clipped line with an ellipsis. The clause states the layout that makes FR6's maxLines take 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 own maxLines. 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.
  • The Chromium spec runs in this PR's browser accessibility CI; before/after captures follow from its Storybook build.

LOC

+106 / −2 across 5 files: 11 lines of source, plus the story, spec, record and changeset.

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.
@vercel

vercel Bot commented Oct 30, 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 Oct 31, 2026 6:15am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 30, 2026
@astracat-bot

astracat-bot Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 31, 2026, 7:06 AM UTC

@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Oct 30, 2026
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Oct 30, 2026
@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

Component Size

Component Import before Import after Delta CSS before CSS after Delta
core/Link 45.9KB 45.9KB +48B 7.9KB 7.9KB +26B
core/LinkProvider 3.5KB 3.5KB 0B 20B 20B 0B
core/SideNavHeading 60.9KB 60.9KB +15B 10.5KB 10.5KB 0B
core/TopNavHeading 60.3KB 60.3KB +23B 10.3KB 10.3KB 0B
lab/CommentComposer N/A 97.1KB N/A N/A 1.9KB N/A
lab/CommentThread N/A 219.9KB N/A N/A 2.4KB N/A
lab/Comments N/A 224.5KB N/A N/A 2.5KB N/A

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 Summary

Gzip figures measure each package's entry file, not the code an import pulls in.

Package Entry (ESM) Entry gzip before Entry gzip after Delta
@astryxdesign/core 4.9KB 1.2KB 1.2KB 0B
Package stylesheet Gzip before Gzip after Delta
@astryxdesign/core 36.0KB 36.0KB 0B

Accessibility Audit

Status: The accessibility audit did not run on this pull request. It runs after merges to main and before each release; pull requests that touch components run it with the ci:heavy-lanes label.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@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.

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)

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.

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.

@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.

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.ts to Link.truncation.a11y.chromium.spec.ts and update the FR6 verification row and verified_by, since playwright.config.ts only collects *.a11y.chromium.spec.ts.
  • Start the changeset body with [fix] and add a contributor handle on its own line, so pnpm check:changesets and the lint check pass.

[Automated review]

Comment thread .changeset/link-maxlines-truncates.md Outdated
'@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.

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.

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.

@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.

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.ts to Link.truncation.a11y.chromium.spec.ts and update the FR6 verification row and verified_by, since playwright.config.ts only collects *.a11y.chromium.spec.ts and 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.

@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.

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]

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec f35a7c3

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Oct 31, 2026

@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.

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]

@cixzhang
cixzhang merged commit 2782f99 into main Oct 31, 2026
65 checks passed
@github-actions
github-actions Bot deleted the fix/link-maxlines-cap branch November 1, 2026 06:05

This branch was successfully deployed

1 active deployment
Preview — f35a7c3d Deployed Oct 31, 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. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant