Repository navigation
fix(Breadcrumbs): let the nav shrink in a flex row so menu modes collapse - #8750
mattcosta7 wants to merge 2 commits into
Conversation
…apse Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
🦋 Changeset detectedLatest commit: e82a581 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the Breadcrumbs flex-layout collapse fix.
No open issues 🎉
What changed in this PR
Fixes delayed Breadcrumbs collapse when the component shares a flex row with sibling content. Menu modes can now shrink to the available space without changing the public API.
Changes:
- Sets
min-width: 0on the Breadcrumbs nav formenuandmenu-with-rootmodes. - Adds a browser regression test for collapse beside a shrinkable sibling.
- Adds a patch changeset for
@primer/react.
| File | Description |
|---|---|
packages/react/src/Breadcrumbs/Breadcrumbs.module.css |
Allows menu-mode navigation to shrink within flex layouts. |
packages/react/src/Breadcrumbs/__tests__/BreadcrumbsOverflow.test.tsx |
Tests collapse when breadcrumbs share limited width with a sibling. |
.changeset/breadcrumbs-shrink-in-flex-row.md |
Documents the flex-layout fix for a patch release. |
Review effort: Balanced
Closes #
In
menuandmenu-with-rootmodes, Breadcrumbs collapsed late, and at different widths depending on crumb length, when placed in a flex row beside other content, as in the github/github-ui global header (ContextRegioninsideTopNav.Center).The
<nav>is a flex item with the defaultmin-width: auto, so it can't shrink below its crumbs. Its siblings absorb the squeeze first, the crumbs keep measuring as fitting, and nothing collapses until those siblings reach their minimum widths. Longer repo names reach that point at a wider viewport. Narrowing and widening also disagreed, by about 150px for long names.This sets
min-width: 0on the nav in the menu modes, so the crumbs are fitted to the width the parent actually offers.Measured in a Storybook mock of the header layout (not github-ui itself). Each cell is the header width where the collapse changes, narrowing / widening:
reactgithub-uiprimer-design-system-componentsa-very-long-repository-name-for-testingThis is not a regression from #8683 or #8748. The implementation before #8683 never collapsed in this layout, and its crumbs spilled up to 249px outside the nav. A per-frame resize harness showed no change in collapse timing or frame times across before #8683, current
main, and this branch.Changelog
New
Changed
overflow="menu"/"menu-with-root"): the nav can shrink below its content as a flex item, so crumbs collapse as soon as they stop fitting.Removed
Rollout strategy
Testing & Reviewing
npx vitest run --project '@primer/react' packages/react/src/Breadcrumbs: passed (3 files, 53 tests). The new test fails without the CSS change (expected [ 'owner', 'repository' ] to deeply equal [ 'repository' ]).npx stylelint -q --rd packages/react/src/Breadcrumbs/Breadcrumbs.module.css: passed.npx eslint packages/react/src/Breadcrumbs/__tests__/BreadcrumbsOverflow.test.tsx: passed.npx prettier --checkon changed files: passed.npm test,npm run type-check, VRT, and the github-ui integration workflow.Risk: any consumer that relied on a menu-mode nav refusing to shrink in a flex row will now see crumbs collapse earlier. A github-ui integration run would confirm the header behaves as in the mock.