Skip to content

Conversation

@kendallgassner
Copy link
Contributor

New

This pull request creates filteredActionList props that allows users to add virtualization to the SelectPanel componenet. The new props are:

  • focusOutBehavior
  • scrollContainerRef
  • actionListProps
Wonky issue to avoid when using useVirtualizer

TanStack useVirtualizer, the virtualizer hook used in the provided storybook example, does not work well when the scrollable parent element (i.e. getScrollElement: () => scrollRef.current,) is located in a child component and observed via a ref. If that DOM element isn’t present at the right point in the component lifecycle, the observation needed for scroll and transform calculations in useVirtualizer may not initialize correctly—leading to rendering or virtualization problems. This happens because useVirtualizer depends on the referenced element being available and stable during initial render or specific lifecycle events to set up its observers and calculations correctly.

The workaround: Use a callback ref with useState for the parent element.

Changed

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
Copy link

changeset-bot bot commented Nov 19, 2025

🦋 Changeset detected

Latest commit: 8d689d3

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 Nov 19, 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.

@kendallgassner kendallgassner marked this pull request as ready for review November 19, 2025 22:49
@kendallgassner kendallgassner requested a review from a team as a code owner November 19, 2025 22:49
@github-actions github-actions bot requested a deployment to storybook-preview-7220 November 19, 2025 22:52 Abandoned
Copilot finished reviewing on behalf of kendallgassner November 19, 2025 23:00
@github-actions github-actions bot temporarily deployed to storybook-preview-7220 November 19, 2025 23:01 Inactive
Copy link
Contributor

Copilot AI left a comment

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 exposes three new props for the SelectPanel component to enable virtualization support: focusOutBehavior, scrollContainerRef, and actionListProps. These props are passed through to the underlying FilteredActionList component, allowing users to implement virtual scrolling for large datasets using libraries like TanStack Virtual.

Key changes:

  • Added @tanstack/react-virtual as a devDependency for Storybook examples
  • Exposed three new props in FilteredActionList that are automatically available in SelectPanel via prop spreading
  • Created a comprehensive Virtualized example story demonstrating integration with TanStack's useVirtualizer

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
packages/react/src/SelectPanel/SelectPanel.examples.stories.tsx Added new Virtualized example story demonstrating virtualization with TanStack Virtual, updated NUMBER_OF_ITEMS constant from 500 to 1800 for better performance demonstration
packages/react/src/FilteredActionList/FilteredActionList.tsx Added three new props (scrollContainerRef, actionListProps, focusOutBehavior) to support virtualization, updated focus zone configuration and useEffect dependencies
packages/react/package.json Added @tanstack/react-virtual ^3.13.12 as devDependency for Storybook examples
package-lock.json Lock file updates for the new TanStack Virtual dependency and its core package
.changeset/salty-geese-say.md Changeset documenting the minor version bump for exposing virtualization props

Copy link
Contributor

@adierkens adierkens left a comment

Choose a reason for hiding this comment

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

Looks great! Added a few small suggestions

Copy link
Contributor

@adierkens adierkens left a comment

Choose a reason for hiding this comment

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

:shipit:

@kendallgassner kendallgassner added this pull request to the merge queue Nov 20, 2025
Merged via the queue into main with commit 62fc3bb Nov 20, 2025
49 checks passed
@kendallgassner kendallgassner deleted the kendallg/virtualizationOnStorybook branch November 20, 2025 21:14
@primer primer bot mentioned this pull request Nov 20, 2025
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.

4 participants