Skip to content

UnderlineNav: Replace dynamic icon visibility logic with hardcoded breakpoints#8133

Merged
jonrohan merged 18 commits into
mainfrom
underlinenav-hardcoded-breakpoints
Jul 8, 2026
Merged

UnderlineNav: Replace dynamic icon visibility logic with hardcoded breakpoints#8133
jonrohan merged 18 commits into
mainfrom
underlinenav-hardcoded-breakpoints

Conversation

@iansan5653

@iansan5653 iansan5653 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #7823

This PR is an alternative approach to #8108 to resolve https://github.com/github/primer/issues/6806.

The problem is that some flickering is inevitable if we want to dynamically hide the icons: we have to let the container overflow in order to detect it and hide the icons, but then when we hide the icons the container no longer overflows. We can minimize flickering but we can never eliminate it with the dynamic approach. Dynamically hiding icons inherently creates an infinite feedback loop.

This PR proposes a simpler, less dynamic alternative: we just hide the icons at hardcoded breakpoints. The breakpoint at which icons are hidden can be controlled by a prop which allows for all the standard Primer breakpoint sizes. The default is very large to avoid breaking existing consumers (namely the global GitHub navigation), but it can easily be reduced by consumers who know they won't be rendering many tabs.

The result is a flicker-free, stable component. However, the drawback is that we sometimes will hide icons early than we would otherwise need to. I think this might be a fair tradeoff.

Also includes some other fixes:

  1. Change overflow anchor button visibility to use display instead of visibility to avoid having to save space for it
  2. Allow the first tab to wrap out of the way on very small screens by rendering an invisible first element

Changelog

New

Changed

  • Replaced UnderlineNav dynamic icon visibility with static breakpoints

Removed

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

@changeset-bot

changeset-bot Bot commented Jul 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8909c5a

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 Minor

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

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

⚠️ Action required

👋 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. If this doesn't work, you can also use the original workflow here. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

To publish a canary release for integration testing, apply the Canary Release label to this PR.

Replaced dynamic icon visibility with static breakpoints to avoid flickering. Breakpoints customizable via the `hideIconBreakpoint` prop.
@iansan5653 iansan5653 added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Jul 7, 2026
@github-actions github-actions Bot requested a deployment to storybook-preview-8133 July 7, 2026 17:02 Abandoned
@github-actions github-actions Bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Jul 7, 2026
@github-actions github-actions Bot temporarily deployed to storybook-preview-8133 July 7, 2026 17:11 Inactive
@github-actions github-actions Bot temporarily deployed to storybook-preview-8133 July 7, 2026 17:22 Inactive
@iansan5653 iansan5653 marked this pull request as ready for review July 7, 2026 17:23
@iansan5653 iansan5653 requested a review from a team as a code owner July 7, 2026 17:23

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Comment thread .changeset/khaki-parrots-eat.md Outdated
Comment thread .changeset/khaki-parrots-eat.md Outdated
Comment thread packages/react/src/UnderlineNav/UnderlineNav.tsx
iansan5653 and others added 2 commits July 7, 2026 14:07
Co-authored-by: Jon Rohan <yes@jonrohan.codes>
Co-authored-by: Jon Rohan <yes@jonrohan.codes>
Copilot AI and others added 2 commits July 8, 2026 14:12
Co-authored-by: iansan5653 <2294248+iansan5653@users.noreply.github.com>
Co-authored-by: iansan5653 <2294248+iansan5653@users.noreply.github.com>
@github-actions github-actions Bot temporarily deployed to storybook-preview-8133 July 8, 2026 14:23 Inactive
@iansan5653 iansan5653 added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Jul 8, 2026
@github-actions github-actions Bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Jul 8, 2026
@github-actions github-actions Bot temporarily deployed to storybook-preview-8133 July 8, 2026 15:24 Inactive
@jonrohan jonrohan added update snapshots 🤖 Command that updates VRT snapshots on the pull request integration-tests: skipped manually Changes in this PR do not require an integration test labels Jul 8, 2026
@github-actions github-actions Bot temporarily deployed to storybook-preview-8133 July 8, 2026 16:04 Inactive
@jonrohan jonrohan added update snapshots 🤖 Command that updates VRT snapshots on the pull request and removed update snapshots 🤖 Command that updates VRT snapshots on the pull request labels Jul 8, 2026
@github-actions github-actions Bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Jul 8, 2026
@jonrohan jonrohan enabled auto-merge July 8, 2026 16:24
@github-actions github-actions Bot temporarily deployed to storybook-preview-8133 July 8, 2026 16:24 Inactive
@jonrohan jonrohan added this pull request to the merge queue Jul 8, 2026
@github-actions github-actions Bot temporarily deployed to storybook-preview-8133 July 8, 2026 16:35 Inactive
Merged via the queue into main with commit 0cb8e17 Jul 8, 2026
54 checks passed
@jonrohan jonrohan deleted the underlinenav-hardcoded-breakpoints branch July 8, 2026 16:40
@primer primer Bot mentioned this pull request Jul 8, 2026
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 integration-tests: skipped manually Changes in this PR do not require an integration test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UnderlineNav performance optimizations

4 participants