Skip to content

fix(Breadcrumbs): "Maximum update depth exceeded" with multi-part crumbs in menu overflow - #8827

Open
MattFor wants to merge 1 commit into
primer:mainfrom
MattFor:fix/breadcrumbs-8790-update-depth
Open

MattFor wants to merge 1 commit into
primer:mainfrom
MattFor:fix/breadcrumbs-8790-update-depth

Conversation

@MattFor

@MattFor MattFor commented Nov 23, 2026 •

Copy link
Copy Markdown

Closes #8790

Description

Since 38.46.0, Breadcrumbs with overflow="menu" or "menu-with-root" can flip between its plain and menu layouts until React throws "Maximum update depth exceeded" (minified React error 185 in production unmounts the tree)

It happens when a crumb measures wider in the plain layout than in the menu layout. Since #8748, getCrumbWidth measures everything in the li, but the two li styles lay that content out differently:

  • li.ItemWrapper is inline-block and li.BreadcrumbsItem is an inline-grid. A space between a crumb's link and its sibling takes up width in the first and isn't rendered in the second (3.64px below).
  • .ItemWrapper sets font-size, while .BreadcrumbsItem inherits it. A sibling in a nav with a smaller font measures differently in each.

The layout effect measures again on every fit change. Measured plain, the crumbs don't fit, so they collapse. Measured in the menu layout, they fit, so they expand, and so on. It only happens within a few px just below the width where all crumbs fit, but resizing through that width is enough.

Steps to reproduce

The CrumbWithPicker from the #8748 test, with one {' '} added:

function CrumbWithPicker() {
  return (
    <>
      <Breadcrumbs.Item href="#repository">repository</Breadcrumbs.Item>{' '}
      <button type="button" style={{width: 24}}>
        Switch
      </button>
    </>
  )
}

<div style={{width: 336}}>
  <Breadcrumbs overflow="menu">
    <Breadcrumbs.Item key="owner" href="#owner">
      organization-with-a-long-name
    </Breadcrumbs.Item>
    <CrumbWithPicker key="repository" />
  </Breadcrumbs>
</div>

This throws on mount at 334-337px in Chrome on Linux. The window depends on fonts: it was 321-340px across Chrome 149, Firefox 153, Safari 18.6 and Edge 153. Each measure pass alternates between these:

plain layout: "repository" = <a> 67.25 + " " 3.64 + <button> 47.27 = 118.16px -> 337.27px needed > 336px -> collapse
menu layout:  "repository" = <a> 67.25 + " " 0.00 + <button> 47.27 = 114.52px -> 333.63px needed <= 336px -> expand

I ran checks on every container width, 600 configurations of crumb shape, count, mode and font size.

  • It reproduces in all four browsers above, with React 18 and 19, on mount, on resize in either direction, and on hydration.
  • 38.46.0 crashes in 200 configurations: every multi-part crumb setup where the plain layout can occur. Plain Breadcrumbs.Item crumbs never crash, and neither does CrumbWithPicker without the space.
  • The 0.0.0-20261109223425 canary crashes in none. Its Breadcrumbs.js differs from 38.46.0 only by fix(Breadcrumbs): measure every element a crumb renders #8748's getCrumbWidth.

I have a fix verified against the same matrix: keep each crumb's width per layout, so the fit check uses plain-layout widths and the menu arrangement uses menu-layout widths.

P.S. #8747 would revert #8683 and bring back the hang from #8739.

Version

38.46.0 / main

Browser

Edge, Firefox, Safari, Chrome

@MattFor
MattFor requested a review from a team as a code owner November 23, 2026 22:13
@changeset-bot

changeset-bot Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e7533f3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

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

…bs in menu overflow

Fixes primer#8790. Since primer#8748, getCrumbWidth measures all of a crumb's content,
but the plain (inline-block) and menu (inline-grid) li layouts measure that
content differently (inter-node whitespace, inherited font size). The fit
check flip-flopped a few px below the collapse threshold until React threw
'Maximum update depth exceeded' and unmounted the tree.

Keep each crumb's measured width per layout and use plain-layout widths for
the plain check, menu-layout widths for the menu check.
@MattFor
MattFor force-pushed the fix/breadcrumbs-8790-update-depth branch from 5d5389a to e7533f3 Compare November 23, 2026 22:21
@MattFor MattFor changed the title Breadcrumbs: fix 'Maximum update depth exceeded' with multi-part crumbs fix(Breadcrumbs): "Maximum update depth exceeded" with multi-part crumbs in menu overflow Nov 23, 2026

This branch was successfully deployed

1 active deployment
github-pages — e7533f32 Deployed Nov 23, 2026 by MattFor via deploy-preview #30822
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Breadcrumbs: "Maximum update depth exceeded" with multi-part crumbs (regression from #8748)

1 participant