Skip to content

fix(TopNav): let the heading shrink so a long heading truncates inside its column - #9551

Merged
cixzhang merged 16 commits into
meta:mainfrom
WeAreResilience:fix/9530-topnav-heading-shrink
Nov 8, 2026
Merged

cixzhang merged 16 commits into
meta:mainfrom
WeAreResilience:fix/9530-topnav-heading-shrink

Conversation

@WeAreResilience

@WeAreResilience WeAreResilience commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #9530

User impact

On the current base (where a crowded TopNav wraps its rows), a TopNav heading wider than the whole bar ran off the bar and scrolled the page sideways, and a TopNavHeading set to truncate never showed its ellipsis. Now the heading ends in an ellipsis inside the bar and its logo stays whole. Independently linked lines wrap and keep their longest word; a plain line beside them still keeps its full width.

Problem and solution fit

The div that wraps heading has flexShrink: 0, but the section that holds it (leftSection: flex: 1 1 0%, minWidth: 0) does shrink. So when the bar is tight, the section narrows and the heading keeps its full width, overflowing the section. Because nothing narrows the heading, its own truncation never triggers.

Expected behavior and authority

The issue lays out the expected outcome: the heading wrapper shrinks with its section, so a heading that can truncate does so inside its column. leftSection already opts in with minWidth: 0, and the wrapper was the one link in that chain that didn't.

Smallest restoration

Reshaped by a maintainer (with the author's attribution kept) after review: the first version's minWidth: 0 let a crowded bar shrink the heading to nothing, logo included. The maintainers read TopNavHeading FR1 as deciding that the text column truncates first and the logo never shrinks; FR1 now says so.

  • TopNav's heading column gets flexShrink: 1 (it was 0), so it can shrink with its start region, down to its own minimum.
  • TopNavHeading's root lays out as a grid (gridAutoFlow: column, start-justified) instead of a flex row. Its narrowest size is then the logo and the controls beside the text, because the text column (minWidth: 0) adds nothing to it. A crowded bar truncates the text first and never shrinks the logo. Once only the logo is left, the start region overflows as on main.
  • TopNavHeading FR1 gains: "When the start region is crowded, the text column truncates first; the logo never shrinks."
  • The changeset says the heading no longer runs under the center or end content.

Evidence

  • Reproduction before the change: the new test fails on main (flexShrink is '0').
  • Result after the change: the new test passes.
  • Representative unchanged path: the existing TopNav, TopNavMenu and TopNavMegaMenu tests still pass (161 tests).
  • Regression test or other mutation-sensitive proof: TopNav.test.tsx > "lets the heading column shrink so a long heading can truncate". It fails when the style change is reverted.
  • Real Chromium, TopNavCrowdedHeading.a11y.chromium.spec.ts (new), red on main's TopNav 3 of 3, green on this head 3 of 3 (twice):
    • TitleOnly at 420 px with a long heading: on main the heading runs to 517 px, under the Sign in button at 327 px; here it ends at the button, truncates, and the page does not scroll sideways.
    • FullExample at 700 px and 600 px: on main the start items run past the viewport and the page scrolls sideways; here the heading text truncates, the logo stays whole and clear of the first nav item, and nothing scrolls sideways.
  • Representative unchanged path: at 1280 px, 8 TopNav stories are pixel-identical to main. TopNavMobileLongHeading still passes. At 390 px the crowded stories differ as intended. A heading with no logo (Default) truncates its text to nothing before the items move, as FR1's ellipsis rule allows.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • vitest run packages/core/src/TopNav: 161 passed.
  • Full packages/core suite: the only failures are 22 tests in 12 files outside TopNav (Button, Dialog, Popover and others). They fail the same way on an unmodified main in my environment.
  • eslint, tsc --noEmit (core) and check:changesets pass. The pre-commit check:repo passes.
  • I didn't do a real-browser check. The test asserts the computed style in jsdom.

AI-assisted. I opened this as a draft per the contributing guidelines.

Maintainer follow-up (independent links in a crowded bar)

(Posted by Cindy's agent on her behalf.) Carried on this branch with the author's commits kept. Exact head: c30126f.

  • Defect: with independent links (headingHref plus superheadingHref or subheadingHref, no menu), the text track (minmax(0, 1fr)) could shrink to zero. In a crowded bar both links clipped to 0 px, Tab landed on an empty focus ring, and the hidden wrapped words still made the bar taller.
  • Fix: with independent links, the text track is minmax(min-content, 1fr) (auto minmax(min-content, 1fr) with a logo), so the column keeps its longest word and a link is never clipped to nothing. main (with the TopNav row wrap) is merged in. When the start region is crowded, the row wraps before any link is clipped.
  • TopNavHeading FR1 now says: "When the start region is crowded, a heading text column holding independent links keeps its longest word and wraps, and the row wraps before any link is clipped; a heading with no links still truncates first. The logo never shrinks."
  • New story Core/TopNav "Independent Heading Links". TopNavCrowdedHeading.a11y.chromium.spec.ts now checks, on the wrapping base:
    • FullExample at 700, 600 and 390 px: the logo is whole, the heading's box overlaps no other control, and the page does not scroll sideways.
    • TitleOnly at 320 px with a heading wider than the bar: it truncates, ends inside the bar, overlaps nothing, and the page does not scroll.
    • "Independent Heading Links" at 1280, 560 and 480 px: both links have a non-zero width, neither is clipped, the heading overlaps nothing, nothing scrolls, and Tab lands on a visible :focus-visible link.
      These assertions, replayed in real Chrome 157 on this branch's preview, pass in all 7 cases.
  • Real Chrome 157 on this head's preview: at 1280 and 640 px the bar is unchanged (50 px). At 560 and 480 px the row wraps (bar 130 px), both links stay on one line at 141 px with nothing clipped, and the page does not scroll sideways. On the head before this fix, at 480 px both links were 0 px wide and Tab landed on an empty ring.

Writing rubric results

R1 narration: none; the FR1 clauses are present-tense sentences.
R2 research: none in the record.
R3 evidence: FR1 keeps its basis; the real-Chromium spec verifies both clauses (truncation first, and independent links keep their longest word).
R4 rejected alternatives: none in the record (a minimum text width or the mobile bar when crowded would be new behavior and are out of scope).
R5 change references: none.
R6 open questions: none.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 2, 2026
@vercel

vercel Bot commented Nov 2, 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 Nov 8, 2026 7:22am UTC

Request Review

@astracat-bot

astracat-bot Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 8, 2026, 3:33 PM UTC

@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 Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · c30126f

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
TopNavHeading 73.9 kB (+209 B) · 11.1 kB CSS (+130 B) — ✓ · ✓ · ✓
TopNavItem 13.7 kB (0) · 4.0 kB CSS (0) — ✓ · ✓ · ✓
TopNavMegaMenu 68.5 kB (0) · 11.7 kB CSS (0) — ✓ · ✓ · ✓
4 more components
Component Size LoC Visual · A11y · RTL
TopNavMegaMenuFeaturedCard 7.3 kB (0) · 3.6 kB CSS (0) — ✓ · ✓ · ✓
TopNavMegaMenuItem 13.7 kB (0) · 4.2 kB CSS (0) — ✓ · ✓ · ✓
TopNavMenu 73.4 kB (0) · 11.2 kB CSS (0) — ✓ · ✓ · ✓
TopNav 71.1 kB (−1 B) · 10.8 kB CSS (0) — ✓ · ✓ · ✓

Package size: @astryxdesign/core 6.99 MB packed (+1.1 kB); no new dependencies.

API changes: none in this pull request

Committed API report behind this build: cli 29 rows, core 40 rows; run pnpm api:report.

Touched components checked; add ci:run-visual, ci:run-a11y or ci:run-rtl to run the full suites.


Generated by PR Enrichment workflow | 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.

Outcome: the fix works (a long heading now truncates with an ellipsis inside its column, and bars that fit are unchanged), but it needs one change and an engineering owner decision before it can be approved.

Required change:

  • .changeset/topnav-heading-shrink.md line 5 says a long heading pushed "the start, center and end content out of the bar", but on main the center and end content stay in place and the heading runs under them, so please reword it, for example "…instead of running under the center or end content (#9530)."

Owner decision: when nav items crowd the default bar, the heading now gives up all of its width: in the TopNav / Full example story at a 700 px viewport, Enterprise Dashboard disappears, and at 600 px the logo and the first item overlap. No current TopNav clause says which part should yield there, so an engineering owner needs to accept this, by commenting /approve-spec <full head SHA> on this pull request, or ask for a different yield order; the author may do so if they are an engineering owner. CI has not run on this head yet: it runs once a maintainer adds the ci:run label.

[Automated review]

Comment thread .changeset/topnav-heading-shrink.md Resolved
Comment thread packages/core/src/TopNav/TopNav.tsx Resolved
cixzhang and others added 3 commits November 5, 2026 14:40
… the logo

The heading column shrinks down to its own minimum instead of to zero.
TopNavHeading lays out as a grid, so its minimum is the logo and the
controls beside the text: the text column truncates first and the logo
never shrinks; once only the logo is left, the start region overflows as
before. TopNavHeading FR1 states it. A real-Chromium spec checks the
700 px and 600 px FullExample and a long heading beside the end content.

Co-authored-by: David Billiot <[email protected]>
… class and checks that the page does not scroll sideways
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 6, 2026
@cixzhang

cixzhang commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 83c22a2

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 6, 2026
astracat-bot[bot]
astracat-bot Bot previously requested changes Nov 6, 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.

Outcome: changes requested. The fix works (a long heading now truncates inside its column, a crowded bar keeps the logo, and bars that fit render as before), but two things need a fix:

  • TopNavHeading's new grid root (TopNavHeading.tsx lines 65-67) leaves the auto margin on headerEndContent nothing to push, so in any root wider than its parts (for example a standalone heading in a 420 px container) the end content now sits right after the text instead of at the inline end that TopNavHeading FR1 requires; sizing the text column's track minmax(0, 1fr) (auto minmax(0, 1fr) after a logo) restores it without changing how a crowded bar behaves.
  • The changeset's second sentence says a crowded TopNavHeading "truncates its text first", but linked lines wrap (FR1), so in the independent-links configuration the heading wraps to three lines and the bar grows from 50 to 90 px; please reword it, for example "…narrows its text first (one-line text truncates and linked lines wrap) and keeps its logo."

Two small comment rewrites are suggested inline and are not blocking. CI has not run on this head yet; it runs once a maintainer adds the ci:run label.

[Automated review]

Comment thread .changeset/topnav-heading-shrink.md Resolved
Comment thread packages/core/src/TopNav/TopNav.tsx Resolved
The text track is minmax(0, 1fr), after an auto logo track when a logo is present, so free space sits in the text and end content stays at the inline end. A crowded bar still narrows the text first and keeps the logo.

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

Outcome: waiting on an engineering owner's decision, plus one required change. A long one-line heading now ends in an ellipsis inside its column, and a crowded bar keeps the logo and the menu chevron.

Required change:

  • With independent links, the new minmax(min-content, 1fr) track (TopNavHeading.tsx lines 91-96) counts a one-line plain line at its full width, so a long plain heading under a linked superheading still never truncates and, in #9530's own repro, still runs under the search field exactly as on main; please make those plain lines truncate as in the other configurations, or narrow the changeset's "a long heading truncates" claim to match.

Decision needed:

  • TopNavHeading FR1's new sentence ("the text column truncates first; the logo never shrinks") was approved at an earlier head, and that approval no longer covers this one; an engineering owner should confirm it together with how crowded linked lines behave here: with independent links they keep their longest word and the bar grows (50 to 85 px at 560 px), while beside a menu they are cut mid-word at the chevron's 32 px with no ellipsis (Miss: the earlier review asked only about the no-menu case).

An engineering owner records the decision by commenting /approve-spec followed by the full head SHA; the author may do so if they are an engineering owner. A small comment rewrite is suggested inline and is not blocking. CI has not run on this head yet; a maintainer adds the ci:run label so it runs.

[Automated review]

Comment on lines +61 to +62
// The text track can shrink to zero. The logo and the chevron row keep
// their width.

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.

Non-blocking (comment accuracy): with menu the track stops at the chevron, and with independent links at the longest linked word. Suggested: The logo keeps its width. The text track yields first, down to the chevron with a menu or the longest word of a linked line.

@cixzhang

cixzhang commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 5e17ac5

1 similar comment
@cixzhang

cixzhang commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 5e17ac5

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 8, 2026
astracat-bot[bot]
astracat-bot Bot previously requested changes Nov 8, 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.

Outcome: changes requested. A TopNavHeading wider than the whole bar now ends in its ellipsis inside the bar instead of scrolling the page sideways, and the new FR1 wording carries an engineering owner's approval for this head. Both fixes below are needed because main's bar-wrapping change was merged in:

  • Regression: a crowded bar now wraps its nav items and end content onto new rows, so 5 of the 6 tests in TopNavCrowdedHeading.a11y.chromium.spec.ts fail (lines 73, 108 and 151); please assert what this change restores (a heading wider than the bar truncates and the page does not scroll sideways) and check that the heading's box overlaps no other region instead of comparing left and right edges.
  • Regression: the changeset (line 5) and the description's user impact say a long heading runs under the center or end content (#9530), which the merged base no longer does, and that one-line text truncates in a crowded bar, which a plain heading under a linked superheading still does not; please narrow it, for example to TopNav's heading can now shrink, so a heading wider than the whole bar ends in an ellipsis instead of running off the bar and scrolling the page sideways (#9530). TopNavHeading keeps its logo whole.

CI has not run on this head yet; a maintainer adds the ci:run label so it runs.

[Automated review]

Comment thread .changeset/topnav-heading-shrink.md Resolved
…roll now that the bar wraps

With the bar's row wrap on main, a crowded bar moves its nav items and
end content to new rows, so comparing left and right edges no longer
holds. The spec now checks that the heading's box overlaps no other
control, that a heading wider than the whole bar truncates, and that
the page does not scroll sideways. The changeset says what this restores
on the current base.

Co-authored-by: WeAreResilience <[email protected]>
@cixzhang

cixzhang commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

/approve-spec c410440

astracat-bot[bot]
astracat-bot Bot previously requested changes Nov 8, 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.

Changes requested: a TopNavHeading wider than the whole bar now ends in its ellipsis instead of scrolling the page sideways, and the rewritten Chromium spec passes on the wrapping bar, but the release note needs one fix.

  • The changeset (.changeset/topnav-heading-shrink.md line 5) and the PR body's user impact claim more than the change does: main never clipped independently linked lines to nothing (the PR's own Independent Heading Links Chromium cases already pass there), and a plain heading under a linked superheading still keeps its full width and scrolls the page sideways when it is wider than the bar.

Suggested changeset wording: TopNav's heading can now shrink, so a heading wider than the whole bar ends in an ellipsis instead of running off the bar and scrolling the page sideways (#9530). TopNavHeading keeps its logo whole, and independently linked lines wrap and keep their longest word; a plain line beside them still keeps its full width. Please also drop the body's "clip to nothing" sentence.

CI has not run on this head yet; a maintainer adds the ci:run label so it runs.

[Automated review]

Comment thread .changeset/topnav-heading-shrink.md Resolved
@cixzhang

cixzhang commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

/approve-spec c30126f

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

Approved. A TopNav heading wider than the whole bar now ends in an ellipsis inside the bar instead of scrolling the page sideways, and TopNavHeading keeps its logo whole. The crowded-heading browser spec's truncation case and the five new unit tests fail on main and pass here, and CI is green on this head.

Optional:

  • The comment at TopNavHeading.tsx:61-62 still says the text track can shrink to zero; with a menu it stops at the chevron box, and with independent links at the longest linked word.
  • The changeset's "ends in an ellipsis" holds for TopNavHeading, but a plain string in heading wraps instead; consider "…a TopNavHeading wider than the whole bar ends in an ellipsis, and other heading content wraps…".

[Automated review]

@cixzhang
cixzhang dismissed stale reviews from astracat-bot[bot], astracat-bot[bot], astracat-bot[bot], and astracat-bot[bot] November 8, 2026 07:55

(Posted by Cindy's agent.) Dismissing as addressed at head c30126f: the latest automated review at this head APPROVES (a heading wider than the bar now ends in its ellipsis inside the bar; the new Chromium truncation case fails on main and passes here). Earlier points are fixed at this head: end-content position, the crowded-bar overlap, the chevron minimum and the logo-only track; the crowded-heading spec now checks overlap and sideways scroll (TopNavCrowdedHeading.a11y.chromium.spec.ts); the changeset uses the reviewer's exact wording. The independent-links behavior follows the recorded TopNavHeading FR1 ruling.

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 8, 2026
@cixzhang cixzhang closed this Nov 8, 2026
@cixzhang cixzhang reopened this Nov 8, 2026
@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Nov 8, 2026
@cixzhang cixzhang added the ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) label Nov 8, 2026
@cixzhang
cixzhang merged commit aba9283 into meta:main Nov 8, 2026
198 of 204 checks passed

This branch was successfully deployed

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

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) 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:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] TopNav: the heading's wrapper never shrinks, so a long heading runs out of its column

2 participants