Repository navigation
fix(Link): in block and inline layout, a long unbroken label such as a bare URL wraps inside its line - #11558
Conversation
A story puts an anchor, a button and an external Link with a bare URL label in a 200 px column, and a Chromium check asks that the column not scroll sideways, that the Link end inside it, and that the label wrap. It fails on main: the label cannot be narrower than its longest word.
Link's inline-flex root grew to its label's longest word, and the label, a flex item, could not shrink below it, so a bare URL ran out of a narrow column and the page scrolled sideways. The root now stops at its container (max-width 100%) and the label may shrink (min-width 0), so the label wraps, as component:Text FR3 asks. The root's own min-width is unchanged, so a Link inside a caller's flex row lays out as before. The Link record says so and names the new Chromium check.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| LinkProvider | 3.8 kB (0) · 20 B CSS (0) | — | ✓ · ✓ · ✗ |
| SideNavHeading | 82.3 kB (+28 B) · 12.1 kB CSS (0) | — | — · — · — |
| Lightbox | 145.1 kB (+21 B) · 11.9 kB CSS (0) | — | — · — · — |
5 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| TopNavHeading | 81.9 kB (+16 B) · 12.0 kB CSS (0) | — | — · — · — |
| lab/CommentComposer | 159.0 kB (+15 B) · 1.9 kB CSS (0) | — | — · — · — |
| lab/Comments | 367.5 kB (+12 B) · 2.5 kB CSS (0) | — | — · — · — |
| Link | 56.2 kB (+11 B) · 7.1 kB CSS (0) | — | ✓ · ✓ · — |
| lab/CommentThread | 360.7 kB (+10 B) · 2.4 kB CSS (0) | — | — · — · — |
Package size: @astryxdesign/core 7.52 MB packed (+146 B); no new dependencies.
Touched components checked; add ci:run-visual or ci:run-rtl to run the full suites.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Changes requested: the Link style fix works in block and inline layout, but its new regression test fails on this head and the changeset claims more than the change fixes.
- The new
Link.longLabel.a11y.chromium.spec.tsfails for all three forms on this head ("the column scrolls sideways") because theLongUnbrokenLabelstory'sdisplay: gridcolumn has anautotrack that grows to the URL's width before and after the change, so render that column as a block (or give the gridgridTemplateColumns: 'minmax(0, 1fr)') and confirm the spec fails on the base and passes here. - The title and changeset say a bare URL now wraps "inside a narrow column", and the description says Markdown's bare URLs break layouts and that a Link in a caller's flex row "lays out as before", but a content-sized grid or table column still overflows, Markdown renders plain anchors that already wrapped before this change, and an over-wide label in a flex row is now capped at the row, so narrow the wording to block and inline layout, name
useLinkify(which renders Link) instead of Markdown, and describe the flex-row change.
Non-blocking: the line-count assertion counts the external icon and the hidden new-tab text as lines, and the comment above truncating still describes the cap that moved to base; see the inline notes.
Claims and files checked
- Claim: a bare-URL label now wraps inside a narrow column (title, changeset): false as worded; true in block and inline layout, not in a content-sized grid or table column.
- Claim: the Link stops at its container and its label may shrink (changeset): verified in
Link.tsx. - Claim: a Link in a line wide enough for its label looks the same (changeset, description): verified; unchanged frames and measurements.
- Claim: Markdown turns bare URLs into Links that break narrow layouts: false; Markdown renders plain anchors that already wrap.
- Claim: the cause is the inline-flex root with a label whose minimum width is its longest word: verified.
- Claim: before the change only a truncating Link stopped at its container: verified.
- Claim: a Link in a caller's flex row lays out as before: false for a label wider than the row.
- Claim: the regression test fails without the fix and passes with it: false; it fails on both.
- Claim: the Link unit tests pass (5 files, 143 tests): verified.
- Claim: the knowledge check passes: verified.
- Claim: no API, prop or default change: verified.
- Claim: the Link record's FR6 describes the fix and names the new check: verified; the check it names fails.
- File
.changeset/link-long-label-wraps.md: wording finding. - File
apps/storybook/stories/Link.stories.tsx: story column finding. - File
docs/specs/components/Link/Link.spec.md: FR6 sentence clear; its verification row cites the failing check. - File
packages/core/src/Link/Link.tsx: clear, with two comment notes. - File
packages/core/src/Link/__tests__/Link.longLabel.a11y.chromium.spec.ts: fails on this head; external line-count note.
The story's column was a grid, and a grid item's minimum width is its content's longest word, so the paragraph around each Link grew to the URL's length and the Link had nothing narrower to stop at. A block column, as a chat or comment column is, gives each paragraph the column's width.
|
/approve-spec f24e48f |
The changeset says the fix holds in block and inline layout, names useLinkify as the source of bare-URL Links, says a flex row now caps an over-wide Link, and says a content-sized grid or table column still grows. The browser check counts only label lines, not the external icon or the hidden new-tab text, and the comment above the truncating style describes what it still does.
|
/approve-spec eccffb9 |
There was a problem hiding this comment.
Changes requested: the Link fix works in block and inline layout and its new spec proves it (it fails without the fix and passes with it), and the code needs no change; one sentence in the description misstates the evidence.
- The description's Evidence section says the external Link wraps onto 5 lines with its icon after the last line, but at this head it wraps onto 3 lines like the anchor and button (counted the way the new spec counts), and the icon sits at the label's end edge, centred beside the middle line (
Link.tsx:71), as the description's own 390 px After image shows, so please correct that sentence.
Non-blocking: the comment above the root's maxWidth in Link.tsx is still one long sentence with three topics; see the earlier inline note.
Claims and files checked
- Claim: in block and inline layout a bare-URL label, such as one from
useLinkify, now wraps inside its line instead of making the page scroll sideways (title, changeset): verified; the new spec fails without the fix and passes here, and a paragraph goes from a 299 px overflow to three lines. - Claim: the Link stops at its container and its label may shrink (changeset, description): verified,
Link.tsx:70,:99-101,:415. - Claim: in a flex row an over-wide label is capped at the row's width and wraps (changeset, description): verified; a Link alone in a 200 px row is 200 px wide on three lines.
- Claim: a Link in a line wide enough for its label looks the same (changeset, description): verified; eight existing stories are pixel-identical and a short label keeps one line.
- Claim: a content-sized grid or table column still grows to the label's longest word (changeset, description): verified; both still grow to 499 px.
- Claim:
useLinkifyturns bare URLs into Links: verified,useLinkify.tsx:202. - Claim: the cause is the inline-flex root and a Text flex item whose minimum width is its longest word, because
break-wordkeeps min-content: verified,Link.tsx:66and Text's display styles. - Claim: before the change only a Link with
maxLinesabove 0 stopped at its container: verified in the base's truncating style. - Claim: the overflow breaks reflow at narrow widths: verified; at 390 px the base page is 529 px wide.
- Claim: two style values change, with no API, prop or default change: verified; the API surface comparison reports no rows.
- Claim: the Link record's FR6 now states the behaviour and its verification row names the new check: verified.
- Claim: before the fix the anchor and button reach x = 515 and the external Link 529, past a column ending at 216, and the anchor and button labels stay on one line: verified, same numbers.
- Claim: after the fix each Link ends at 216, the column does not scroll and the label wraps onto 3 lines: verified.
- Claim: the external Link wraps onto 5 lines with its icon after the last line: false; 3 lines, icon centred beside the middle line.
- Claim: the story column is now a block, because a grid item grows to its longest word: verified,
Link.stories.tsx:205; an auto grid track still grows to 499 px. - Claim: the regression test checks that the column does not scroll, the Link ends inside it and the label wraps, and fails without the fix: verified; 3 failed without the fix and 3 passed here.
- Claim: the Link unit tests pass (5 files, 143 tests) and the knowledge check passes: verified.
- Claim: no new public API, default or interaction model, and no internal context in public text: verified.
- File
.changeset/link-long-label-wraps.md: clear. - File
apps/storybook/stories/Link.stories.tsx: clear. - File
docs/specs/components/Link/Link.spec.md: clear; the FR6 amendment is owner-approved at this head. - File
packages/core/src/Link/Link.tsx: clear, with one non-blocking comment-style note. - File
packages/core/src/Link/__tests__/Link.longLabel.a11y.chromium.spec.ts: clear.
There was a problem hiding this comment.
Approved pending CI: the Link fix holds, and CI has not run on this head yet because the CI workflow skips drafts; it runs once the pull request is marked ready for review.
The earlier evidence sentence about the external Link now matches what renders (three lines, icon centred at the label's end), and the new Chromium spec fails without the fix and passes with it.
- Non-blocking: the in-a-sentence case that the title and the description's stills show is not in the committed story or spec; adding that paragraph to
LongUnbrokenLabeland a fourth spec case would keep the inline claim under CI. - Non-blocking: the comment above the root's
maxWidthinLink.tsxis still one long sentence with three topics; see the earlier inline note.
Claims and files checked
- Claim: in block and inline layout a bare-URL label, such as one from
useLinkify, now wraps inside its line instead of making the page scroll sideways (title, changeset): verified; the new spec fails on the base and passes here, and a probe wraps a Link alone in its paragraph and inside a sentence onto three lines within 200 px, in both directions. - Claim: the Link stops at its container and its label may shrink (changeset, description): verified,
Link.tsx:70,:94-101,:415. - Claim: in a flex row an over-wide Link is capped at the row's width and wraps (changeset, description): verified; a Link alone in a 200 px row is 200 px wide on three lines.
- Claim: a Link in a line wide enough for its label looks the same (changeset, description): verified; nine existing story frames are pixel-identical and a short label keeps one line.
- Claim: a content-sized grid or table column still grows to the label's longest word (changeset, description): verified; both still grow to 499 px.
- Claim:
useLinkifyturns bare URLs into Links: verified,useLinkify.tsx:202. - Claim: the cause is the inline-flex root and a Text flex item whose minimum width is its longest word, because
break-wordkeeps min-content: verified,Link.tsx:66and Text's display styles. - Claim: before the change only a Link with
maxLinesabove 0 stopped at its container: verified in the base's truncating style. - Claim: the overflow breaks reflow at phone width: verified; at 390 px the base column and page scroll sideways.
- Claim: the Link record says the label renders inside Text, and the Text record requires an untruncated token to wrap and a flex child's container to give it a zero minimum width: verified against both records.
- Claim: two style values change, with no API, prop or default change: verified; the API surface comparison reports no rows.
- Claim: the Link record's FR6 now states the behaviour and its verification row names the new check: verified.
- Claim: before the fix the anchor and button reach x = 515 and the external Link 529, past a column ending at 216, the column scrolls, and the anchor and button labels stay on one line: verified, same numbers.
- Claim: after the fix each Link ends at 216, the column does not scroll, and each label, the external one included, wraps onto 3 lines with the icon at its end edge centred beside the middle line: verified.
- Claim: the stills show the block and in-sentence layouts in both directions, with each Link on one line past the column before and on 3 lines inside it after, the in-sentence box sitting between the text before and after it: verified against all eight stills and by probe; the in-sentence case is not in the committed story.
- Claim: the story column is now a block, because a grid item grows to its longest word: verified,
Link.stories.tsx:205; an auto grid track still grows to 499 px. - Claim: the regression spec checks that the column does not scroll, the Link ends inside it and the label wraps, and it fails without the fix and passes with it: verified; 3 failed without the fix and 3 passed here.
- Claim: the Link unit tests pass (5 files, 143 tests) and the knowledge check passes: verified.
- Claim: no new public API, visual representation, default or interaction model, and no internal context in public text: verified.
- File
.changeset/link-long-label-wraps.md: clear. - File
apps/storybook/stories/Link.stories.tsx: clear, with one non-blocking coverage note. - File
docs/specs/components/Link/Link.spec.md: clear; the FR6 amendment is owner-approved at this head. - File
packages/core/src/Link/Link.tsx: clear, with one non-blocking comment-style note. - File
packages/core/src/Link/__tests__/Link.longLabel.a11y.chromium.spec.ts: clear.
| // A block column, as a chat or comment column is: a grid or flex item | ||
| // would grow to the URL's length before the Link could wrap. | ||
| <div style={{width: 200}}> | ||
| {(['anchor', 'button', 'external'] as const).map(form => ( |
There was a problem hiding this comment.
Non-blocking: the title and the description's stills also cover a Link inside a sentence, but this story only renders each Link alone in its paragraph, so that case is not under CI. A fourth paragraph such as Read the report at <Link …>{url}</Link> before the meeting. here, plus a fourth case in Link.longLabel.a11y.chromium.spec.ts, would lock it. It already wraps correctly with this fix.
There was a problem hiding this comment.
Changes requested: the Link fix itself works, since a bare-URL label now wraps inside its line in block and inline layout and the new Chromium spec fails without the fix and passes with it, but the required lint check now fails on this pull request.
- Found by CI:
lintstops at its comment-provenance check because the new comment atpackages/core/src/Link/Link.tsx:67-69citescomponent:TextFR3, which the comment-provenance baseline does not allow, so drop that citation (for example: "The root stops at its container, so a label with no break opportunity, such as a bare URL, wraps inside the line.").
Non-blocking: that rewrite also brings the comment under the 25-word sentence limit, and a Link-in-a-sentence case in LongUnbrokenLabel and its spec would keep the inline-layout claim under CI.
Claims and files checked
- Claim (changeset): in block and inline layout a bare-URL label, such as one from
useLinkify, now wraps instead of making the page scroll sideways. Verified: in a 200 px column the Link ran 299 px past it (313 px with the external icon) and now wraps onto three lines inside it, alone in a paragraph, in a sentence and in body text; a 320 px page no longer scrolls. - Claim (changeset): the Link stops at its container and its label may shrink. Verified:
Link.tsx:70,:99-101,:415. - Claim (changeset): in a flex row an over-wide Link is capped at the row's width and wraps. Verified: 499 px to 200 px on three lines.
- Claim (changeset): a Link that fits its line looks the same. Verified: a short label is unchanged and eight existing Link stories render pixel-identical.
- Claim (changeset): a content-sized grid or table column still grows to the label. Verified: both stay 499 px wide.
- Claim (description): the cause is the inline-flex root and a flex-item label whose minimum width is its longest word, and only a truncating Link was capped before. Verified in the base and head source.
- Claim (description): two style values and no API, prop or default change. Verified: the API surface comparison lists no change.
- Claim (description): Text FR3 and Link FR6 govern, and the Link record now states the wrap and names the new check. Verified:
Link.spec.md:20,:117,:202. - Claim (description): before, the Links end at x = 515 and 529 against a column that ends at x = 216; after, at 216 on three lines with the external icon beside the middle line. Verified: the same numbers in Chromium.
- Claim (description): the stills show block and in-sentence layout, left to right and right to left. Verified in the stills; the sentence case is not in the committed story.
- Claim (description): the new spec fails without the fix and passes with it. Verified: 3 of 3 fail on the base, 3 of 3 pass on the head.
- Claim (description): the Link unit tests (5 files, 143 tests) and the knowledge check pass. Verified.
- File
.changeset/link-long-label-wraps.md: clear. - File
apps/storybook/stories/Link.stories.tsx: clear (non-blocking: no in-sentence case). - File
docs/specs/components/Link/Link.spec.md: clear. - File
packages/core/src/Link/Link.tsx: blocking finding at lines 67-69 (lint). - File
packages/core/src/Link/__tests__/Link.longLabel.a11y.chromium.spec.ts: clear.
|
/approve-spec 50fc819 |
There was a problem hiding this comment.
Approved: CI passes on this head.
The fix holds: a bare-URL Link label now wraps inside its line in block and inline layout, alone in a flex row, and on a 320 px page, while short labels, truncation and clamped text render exactly as before. The new Chromium spec passes on this head, and the same layout on main's Link overflows its column, so the spec catches a regression.
Non-blocking, both already noted inline: an in-sentence case in LongUnbrokenLabel and its spec would keep inline layout under CI, and the comment at Link.tsx:67-69 can shrink to one sentence.
Claims and files checked
- Claim (changeset): in block and inline layout, a bare-URL label, such as one from
useLinkify, now wraps instead of making the page scroll sideways. Verified: in a 200 px column main's Link runs 299 px past it (313 px with the external icon) on one line; here it wraps onto three lines inside it, alone in a paragraph and inside a sentence; a 320 px page goes from 545 px wide to 320 px. - Claim (changeset): the Link stops at its container and its label may shrink. Verified:
Link.tsx:70,:99-101,:415. - Claim (changeset): in a flex row, an over-wide Link is capped at the row and wraps. Verified: 499 px to 200 px, on three lines.
- Claim (changeset): a Link that fits its line looks the same. Verified: short and multi-word labels and nine existing Link stories render pixel-identically.
- Claim (changeset): a content-sized grid or table column still grows to the label. Verified: both stay 499 px wide, before and after.
- Claim (description): the cause is the inline-flex root with a flex-item label whose minimum width is its longest word, and only a truncating Link stopped at its container before. Verified in main's and this head's source.
- Claim (description): two style values, with no API, prop or default change. Verified: the API surface comparison lists no change.
- Claim (description): the Text reflow rule and the Link label rule govern, and the Link record now states the wrap and names the new check. Verified:
Link.spec.md:20,:117,:202. - Claim (description): before, the Links end at x = 515 and 529 against a column ending at x = 216; after, at 216 on three lines, with the external icon beside the middle line. Verified with the same layout in Chromium.
- Claim (description): in a sentence, the Link's wrapped lines sit between the text before and after it, left to right and right to left. Verified; this case is not in the committed story.
- Claim (description): the new spec fails without the fix and passes with it. Verified: it passes in CI on this head, and the same layout on main's Link fails each of its three checks.
- Claim (description): the Link unit tests (5 files, 143 tests) and the knowledge check pass. Verified.
- File
.changeset/link-long-label-wraps.md: clear. - File
apps/storybook/stories/Link.stories.tsx: clear (non-blocking: no in-sentence case). - File
docs/specs/components/Link/Link.spec.md: clear. - File
packages/core/src/Link/Link.tsx: clear (non-blocking comment wording at lines 67-69). - File
packages/core/src/Link/__tests__/Link.longLabel.a11y.chromium.spec.ts: clear.
| // The root stops at its container, and the label below can shrink. Thus | ||
| // a label with no break opportunity, such as a bare URL, wraps inside the | ||
| // line and does not push past it. |
There was a problem hiding this comment.
Non-blocking (source comment style): the first sentence carries two topics, and "the label below can shrink" repeats the comment on label at lines 97-98, while "and does not push past it" restates "wraps inside the line". One sentence keeps the reason:
| // The root stops at its container, and the label below can shrink. Thus | |
| // a label with no break opportunity, such as a bare URL, wraps inside the | |
| // line and does not push past it. | |
| // The root stops at its container, so a label with no break opportunity, | |
| // such as a bare URL, wraps inside the line. |
User impact
In block and inline layout, a Link whose label has no break opportunity, such as a bare URL, runs past the end of a narrow column and makes the column, or the whole page at phone width, scroll sideways.
useLinkifyturns bare URLs in text into Links, so a message or comment with a long URL breaks the layout of a side panel or a phone screen.Problem and solution fit
display: inline-flex, and its label is a Text flex item. Text setsoverflow-wrap: break-word, which does not lower the minimum content width, and a flex item'smin-widthdefaults to that width, so neither the root nor the label can be narrower than the longest word. Only a Link withmaxLinesabove 0 stopped at its container.max-width: 100%) and the label may shrink (min-width: 0), in every case, so the label wraps as plain Text does. In a flex row, a Link whose label is wider than the row is now capped at the row's width and wraps; a Link that fits looks the same. A content-sized grid or table column still grows to the label's longest word, as it does for plain Text.Expected behavior and authority
component:LinkFR6: the label renders inside Text.component:TextFR3: without truncation, a token longer than its line wraps, so ordinary flow does not force horizontal scrolling at 320 CSS px (spec:AST-020FR1); a flex child needsmin-width: 0from its container. Link's root is that container.Smallest restoration
Two style values in
Link.tsx:max-width: 100%on the root (moved from the truncating style, which keepsmin-width: 0) andmin-width: 0on the label. No API, prop or default change. The Link record's FR6 says the root stops at its container and the label wraps, and names the new check.Evidence
Link / Long Unbroken Labelstory (an anchor, a button and an external Link with a bare URL label in a 200 px column). Real Chrome, light theme, at 390 px and 1280 px wide, from the Vercel previews of the first commit (main's Link code with the new story and check) and of the fix. The column is 200 px wide and ends at x = 216.Each frame shows the 200 px column in block layout (an anchor, a button and an external Link, each alone in its paragraph) and in inline layout (the anchor Link inside a sentence), left to right and right to left. On every frame, before: each Link runs past the column, the column scrolls sideways, and the label stays on one line; after: each Link ends inside the column, nothing scrolls, and the label wraps onto 3 lines. In the sentence, the Link's box is atomic (
inline-flex), as before, so its wrapped lines sit between the text before and after it.The story's column is a plain block, as a chat or comment column is (third commit). In the first version of the story it was a grid, and a grid item grows to its longest word, so the paragraph around each Link was as wide as the URL and no Link could wrap; the stills were taken with the column set to block, which is what the story now renders.
Link.longLabel.a11y.chromium.spec.tsasks, for each form, that the column not scroll sideways, that the Link end inside it, and that the label wrap. The first commit adds it alone; it fails there (each Link runs past the column) and passes with the fix.Scope
Components: Link
Testing
vitest run --project ui packages/core/src/Link: 5 files, 143 tests pass.pnpm check:knowledgepasses.Owner and land path