Skip to content

Replace ActionBar overflow calculations with CSS wrapping approach - #7655

Merged
francinelucca merged 31 commits into
mainfrom
actionbar-css
Apr 28, 2026
Merged

Replace ActionBar overflow calculations with CSS wrapping approach#7655
francinelucca merged 31 commits into
mainfrom
actionbar-css

Conversation

@iansan5653

@iansan5653iansan5653 commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

Takes the CSS flex wrapping approach to detecting overflowing from #7506 and applies it to ActionBar, resulting in a much simpler and more reliable solution that is also SSR-stable:

Screen.Recording.2026-03-11.at.2.37.39.PM.mov

Compare to the current implementation, which flickers on load and doesn't calculate the overflow as accurately, causing items to occasionally get clipped (this is more noticeable on production where it can sometimes calculate the overflow incorrectly; but that's hard to show in Storybook):

Screen.Recording.2026-03-11.at.2.42.41.PM.mov

Changelog

New

Changed

Improves ActionBar overflow calculations and SSR support

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

@changeset-bot

changeset-botBot commented Mar 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 30ea75a

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

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

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-actionsgithub-actionsBot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Mar 11, 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. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

@iansan5653
iansan5653 marked this pull request as ready for review March 11, 2026 18:45
@iansan5653
iansan5653 requested a review from a team as a code ownerMarch 11, 2026 18:45
@github-actions
github-actionsBot requested a deployment to storybook-preview-7655 March 11, 2026 18:49 Abandoned

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 refactors ActionBar overflow handling away from JS width calculations and towards a CSS wrapping + overflow-clipping approach (similar to the UnderlineNav work), aiming to reduce flicker and improve SSR stability.

Changes:

  • Replaces ResizeObserver/width math with CSS wrapping + scroll-driven overflow detection.
  • Introduces a per-item overflow registration mechanism using useSyncExternalStore + IntersectionObserver.
  • Adds a changeset for a minor release of @primer/react.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

FileDescription
packages/react/src/ActionBar/ActionBar.tsxReworks overflow detection and overflow menu population to use descendant registry updates driven by wrapping/overflow state.
packages/react/src/ActionBar/ActionBar.module.cssAdds wrapping container + scroll-timeline based detection to control overflow button visibility.
.changeset/many-suns-promise.mdDeclares the change as a minor release.
Comments suppressed due to low confidence (1)

packages/react/src/ActionBar/ActionBar.tsx:433

  • ref is cast to RefObject from forwardedRef, but forwardedRef can be a callback ref at runtime. useActionBarItem reads ref.current, which will throw if a callback ref is passed. Consider using an internal useRef plus useRefObjectAsForwardedRef/useMergedRefs so you always have a real object ref for measurements and can still forward refs safely.
export const ActionBarGroup = forwardRef(({children}: React.PropsWithChildren, forwardedRef) => {
const backupRef = useRef<HTMLDivElement>(null)
const ref = (forwardedRef ?? backupRef) as RefObject<HTMLDivElement>
const {id, isOverflowing} = useActionBarItem(
ref,
useMemo((): ChildProps => ({type: 'group'}), []),

Comment threadpackages/react/src/ActionBar/ActionBar.tsx
Comment threadpackages/react/src/ActionBar/ActionBar.tsx
Comment threadpackages/react/src/ActionBar/ActionBar.tsx Outdated
Comment threadpackages/react/src/ActionBar/ActionBar.tsx Outdated
Comment threadpackages/react/src/ActionBar/ActionBar.tsx Outdated
Comment threadpackages/react/src/ActionBar/ActionBar.tsx
@github-actions
github-actionsBot requested a deployment to storybook-preview-7655 March 11, 2026 18:57 Abandoned
@github-actions
github-actionsBottemporarily deployed to storybook-preview-7655 March 11, 2026 19:08 Inactive

@francineluccafrancinelucca left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something's off here 👀

Screen.Recording.2026-03-11.at.3.14.32.PM.mov

Comment threadpackages/react/src/ActionBar/ActionBar.module.css Outdated
@iansan5653

Copy link
Copy Markdown
ContributorAuthor

something's off here 👀

Should be resolved now by setting visibility:hidden on those items which will remove them from the tab order. Thanks for catching that!

@github-actions
github-actionsBot requested a deployment to storybook-preview-7655 March 12, 2026 19:27 Abandoned
@github-actions
github-actionsBottemporarily deployed to storybook-preview-7655 March 12, 2026 19:36 Inactive
@francinelucca
francinelucca self-requested a review April 22, 2026 21:08

@francineluccafrancinelucca left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks amazing 😻. Very excited to get this in! thanks for persevering through this 🙏🏽
Also really happy with the code cleanup since last revision ❇️ 🧹

@iansan5653
iansan5653 enabled auto-merge April 23, 2026 16:25
@primer
primerBot disabled auto-merge April 24, 2026 16:22
@primer
primerBot added this pull request to the merge queueApr 24, 2026
@francinelucca
francinelucca removed this pull request from the merge queue due to a manual request Apr 24, 2026
@primer-integration

Copy link
Copy Markdown

👋 Hi from github/github-ui! Your integration PR is ready: https://github.com/github/github-ui/pull/19404

@iansan5653
iansan5653 enabled auto-merge April 27, 2026 13:38
@primer-integration

Copy link
Copy Markdown

Integration test results from github/github-ui:

Passed CI  Passed
Passed VRT  Passed
Passed Projects  Passed

All checks passed!

@iansan5653
iansan5653 disabled auto-merge April 27, 2026 14:50
@iansan5653
iansan5653 enabled auto-merge April 27, 2026 14:50
@iansan5653
iansan5653 disabled auto-merge April 27, 2026 14:50
@github-actions
github-actionsBot requested a deployment to storybook-preview-7655 April 27, 2026 15:55 Abandoned
@github-actions
github-actionsBottemporarily deployed to storybook-preview-7655 April 27, 2026 16:05 Inactive
@iansan5653
iansan5653 enabled auto-merge April 27, 2026 20:29
@primer
primerBot disabled auto-merge April 28, 2026 17:39
@primer
primerBot added this pull request to the merge queueApr 28, 2026
@github-merge-queue
github-merge-queueBot removed this pull request from the merge queue due to failed status checks Apr 28, 2026
@francinelucca
francinelucca added this pull request to the merge queueApr 28, 2026
Merged via the queue into main with commit f59a1b1Apr 28, 2026
102 checks passed
@primerprimerBot mentioned this pull request Apr 28, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Canary ReleaseApply this label when you want CI to create a canary release of the current PRintegration-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.

Avoid flickering when calculating ActionBar overflow

4 participants

@iansan5653@francinelucca@TylerJDev