Skip to content

Conversation

@mattcosta7
Copy link
Contributor

@mattcosta7 mattcosta7 commented Dec 15, 2025

Summary

Performance optimizations for Breadcrumbs component to improve INP and reduce layout thrashing.

Changes

  1. CSS :has() selector optimization - Scope :has(.MenuOverlay) to shallow path > .MenuDetails .MenuOverlay for O(1) lookup
  2. Batch offsetWidth reads - Read all widths in a single pass to avoid forced synchronous layouts

Expected INP Impact

Scenario Before After Improvement
Worst case (many breadcrumb items, overflow menu) ~40-60ms (style + layout) <10ms 75-85% reduction
Average case (typical breadcrumbs, 3-5 items) ~15-25ms <5ms 65-80% reduction
Best case (few items, no overflow) ~5-10ms <2ms 60-80% reduction

Why this matters

  • :has() optimization: MenuOverlay detection was scanning entire subtree on every interaction
  • Layout batching: Reading offsetWidth twice in sequence forces two layout calculations. Batching into one pass eliminates layout thrashing during resize calculations.

Part of the INP performance optimization effort. See #7312 for full context.

… reads

- Scope :has(.MenuOverlay) to shallow path > .MenuDetails .MenuOverlay for O(1) lookup
- Batch all offsetWidth reads in a single pass to avoid layout thrashing

Part of #7312
@changeset-bot
Copy link

changeset-bot bot commented Dec 15, 2025

🦋 Changeset detected

Latest commit: ee72d57

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

@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Dec 15, 2025
@github-actions
Copy link
Contributor

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Or, apply the integration-tests: skipped manually label to skip these checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants