Skip to content

UnderlineNav: Improve flickering by moving icon visibility control to a one-way CSS animation - #8108

Closed
iansan5653 wants to merge 18 commits into
mainfrom
fix-underlinenav-flicker
Closed

UnderlineNav: Improve flickering by moving icon visibility control to a one-way CSS animation#8108
iansan5653 wants to merge 18 commits into
mainfrom
fix-underlinenav-flicker

Conversation

@iansan5653

@iansan5653iansan5653 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

The icons in UnderlineNav can cause flickering as they cause/un-cause the container to overflow when hidden/shown. We use JS to update state to prevent this flickering, but that doesn't run until after hydration. This means that, for certain screen sizes, the icons will flicker after SSR and before client-size hydration.

This PR moves the icon visibility logic to a one-way CSS animation on supported browsers. This way, when the scroll-driven animation is triggered, it triggers the corresponding icon-hiding animation, which persists and keeps the icons hidden for the remaining life of the component.

This improves the performance significantly by shifting the calculations into CSS in supported browsers (ie, not in Firefox). This reduces the visibility of the flickering. However, unfortunately it does not completely resolve the flickering; the browser still has to paint the tabs in order to determine the overflow and then hide the icons.

Changelog

New

Changed

  • Fixed icon flickering before initial render in UnderlineNav

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

Merge checklist

@iansan5653
iansan5653 requested a review from a team as a code ownerJuly 2, 2026 14:57
@changeset-bot

changeset-botBot commented Jul 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fc168b4

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

This PR includes changesets to release 1 package
NameType
@primer/reactPatch

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

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.

@github-actionsgithub-actionsBot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Jul 2, 2026

CopilotAI 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.

Pull request overview

This PR updates UnderlineNav to avoid SSR→hydration icon flicker by removing the JS “has ever overflowed” state and attempting to move icon-hiding logic entirely into CSS via scroll-driven animations.

Changes:

  • Removed hasEverOverflowed state and the data-hide-icons attribute from UnderlineNav.tsx.
  • Added a new hide-icons animation in UnderlineNav.module.css, intended to run once and then keep icons hidden permanently by controlling animation play state via the existing scroll-driven overflow detection.
  • Minor string literal change for the overflow menu button aria-label.
Show a summary per file
FileDescription
packages/react/src/UnderlineNav/UnderlineNav.tsxRemoves JS-based icon hiding (hasEverOverflowed / data-hide-icons) to rely on CSS-only behavior.
packages/react/src/UnderlineNav/UnderlineNav.module.cssAdds a one-shot animation approach intended to hide icons without JS and prevent overflow-driven flicker loops.

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Low

Comment threadpackages/react/src/UnderlineNav/UnderlineNav.tsx
Comment threadpackages/react/src/UnderlineNav/UnderlineNav.module.css
@github-actions
github-actionsBot requested a deployment to storybook-preview-8108 July 2, 2026 15:02 Abandoned
@github-actions
github-actionsBottemporarily deployed to storybook-preview-8108 July 2, 2026 15:19 Inactive
@iansan5653iansan5653 added the Canary Release Apply this label when you want CI to create a canary release of the current PR label Jul 2, 2026
@github-actions
github-actionsBottemporarily deployed to storybook-preview-8108 July 2, 2026 15:57 Inactive
@iansan5653iansan5653 added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Jul 2, 2026
@github-actions
github-actionsBottemporarily deployed to storybook-preview-8108 July 2, 2026 16:16 Inactive
@iansan5653iansan5653 removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm Canary Release Apply this label when you want CI to create a canary release of the current PR update snapshots 🤖 Command that updates VRT snapshots on the pull request labels Jul 2, 2026
@github-actionsgithub-actionsBot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Jul 2, 2026
@github-actions

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.

@github-actions
github-actionsBottemporarily deployed to storybook-preview-8108 July 2, 2026 22:08 Inactive
@llastflowersllastflowers 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 2, 2026
@github-actionsgithub-actionsBot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Jul 2, 2026
@github-actions
github-actionsBottemporarily deployed to storybook-preview-8108 July 2, 2026 23:04 Inactive
@github-actions
github-actionsBottemporarily deployed to storybook-preview-8108 July 2, 2026 23:52 Inactive
@llastflowersllastflowers added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Jul 2, 2026
@github-actionsgithub-actionsBot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Jul 3, 2026
Comment threadpackages/react/src/UnderlineNav/UnderlineNav.module.css Outdated
@iansan5653iansan5653 changed the title UnderlineNav: Fix flickering by moving icon visibility control to pure CSSUnderlineNav: Fix flickering by moving icon visibility control to a one-way CSS animationJul 6, 2026
@github-actions
github-actionsBottemporarily deployed to storybook-preview-8108 July 6, 2026 15:37 Inactive
@primer-integration

Copy link
Copy Markdown

Integration test results from github/github-ui PR:

Failed CI  Failed
Failed VRT  Failed
Passed Projects  Passed

CI check runs linting, type checking, and unit tests. Check the workflow logs for specific failures.

VRT check ensures that when visual differences are detected, the PR cannot proceed until someone acknowledges the changes by adding the "visual difference acknowledged" label.

Need help? If you believe this failure is unrelated to your changes, please reach out to the Primer team for assistance.

@iansan5653iansan5653 changed the title UnderlineNav: Fix flickering by moving icon visibility control to a one-way CSS animationUnderlineNav: Improve flickering by moving icon visibility control to a one-way CSS animationJul 6, 2026
@iansan5653

Copy link
Copy Markdown
ContributorAuthor

Closing in favor of an alternative approach #8133

@primer
primerBot deleted the fix-underlinenav-flicker branch July 8, 2026 00:19
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: recommendedThis 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.

5 participants

@iansan5653@jonrohan@joshblack@llastflowers