Repository navigation
fix(Breadcrumbs): measure every element a crumb renders - #8748
Conversation
A crumb that renders a link plus a sibling button (e.g. github-ui's repository picker) was measured by its first element only, so the fit under-counted it and the crumbs never collapsed, spilling out of end-aligned containers. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
🦋 Changeset detectedLatest commit: a4e90cc 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.
🔵 Needs a closer look
The RepoPicker markup and consumer CSS are outside this checkout, so unverified github-ui integration requires human confirmation of narrow-width collapse and leaf truncation before rollout.
No open issues 🎉
What changed in this PR
Fixes a Breadcrumbs overflow regression introduced by #8683: crumbs containing multiple elements could be under-measured and spill outside the global header.
Changes:
- Measures the span of all elements rendered by a crumb, excluding its separator.
- Adds a browser regression test for a link with a sibling picker button in an end-aligned container.
- Adds a patch changeset for
@primer/react.
| File | Description |
|---|---|
packages/react/src/Breadcrumbs/Breadcrumbs.tsx |
Measures all crumb elements when calculating overflow. |
packages/react/src/Breadcrumbs/__tests__/BreadcrumbsOverflow.test.tsx |
Tests multi-element crumb collapse and container bounds. |
.changeset/breadcrumbs-measure-whole-crumb.md |
Documents the overflow fix for a patch release. |
Review effort: Balanced
Counts text nodes as well as elements, and reads one rect per crumb. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Integration test results from github/github-ui PR: |
Closes #
Fix-forward for the dotcom regression found after #8683 (proposed revert: #8747).
On small screens the global header breadcrumbs (
primer / react ▾) stopped collapsing to··· / re…and instead spilled left over the GitHub logo. #8683 measured each crumb by its first element only. The header's repository crumb renders a link plus a sibling dropdown button (RepoPicker), so the button's width was never counted. The fit decided both crumbs still fit, nothing collapsed, and the end-aligned header region pushed the overflow out of its start edge. Before #8683 the wholeliwas measured, which is why it worked.The fix measures a crumb as the extent of everything it renders, elements and text, excluding the separator. It uses a
Rangeover thelicontents: one rect read per crumb, and no change to the DOM structure. Consumers such as github-ui's header styleli:has(> .repoPickerDropdownButton), so wrapping crumb content would break them.Changelog
New
Changed
Breadcrumbswithoverflow="menu"/"menu-with-root"collapses crumbs that render more than one element (for example a link with a sibling button) when they no longer fit, instead of overflowing the container.Removed
Rollout strategy
Testing & Reviewing
BreadcrumbsOverflow.test.tsxmirrors the header: a link + sibling button crumb in an end-aligned container, sized just below the crumbs' natural width. It fails without the fix (both crumbs stay visible and spill) and passes with it.flex: 1; min-width: 0; justify-content: flex-endcenter, right cluster) showed the left spill at every narrow width before the fix. After the fix, crumbs collapse correctly wherever there's room, and the leaf truncates with….npx vitest run --project '@primer/react' packages/react/src/Breadcrumbs packages/react/src/__tests__/ssr.test.tsx: passed (52 tests)npx eslinton changed files: passednpm run type-check: passed