Skip to content

Conversation

@kendallgassner
Copy link
Contributor

I need to be able to calculate the height of a virtualized item if text overflows. In order to do this I will need to set up a Ref on ActionList.item

Changelog

Ensure MappedActionListItem is a forwardRef component

New

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 Dec 2, 2025

🦋 Changeset detected

Latest commit: 142f013

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

github-actions bot commented Dec 2, 2025

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

@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 2, 2025
@kendallgassner kendallgassner marked this pull request as ready for review December 2, 2025 02:22
@kendallgassner kendallgassner requested a review from a team as a code owner December 2, 2025 02:22
Copilot finished reviewing on behalf of kendallgassner December 2, 2025 02:25
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 converts the MappedActionListItem component to use React's forwardRef, enabling ref forwarding to the underlying ActionList.Item component. This change supports virtualization with dynamic height measurement in the SelectPanel component, allowing proper calculation of item heights when text wraps.

Key Changes:

  • Converted MappedActionListItem from a regular function to a forwardRef component with proper TypeScript typing (forwardRef<HTMLLIElement, ItemInput & {renderItem?: RenderItemFn}>)
  • Updated the Virtualized story in SelectPanel to demonstrate dynamic height measurement using refs and the TanStack Virtual library
  • Added a test item with long text to showcase text wrapping behavior

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/react/src/FilteredActionList/FilteredActionList.tsx Converted MappedActionListItem to a forwardRef component and added ref prop forwarding to ActionList.Item
packages/react/src/SelectPanel/SelectPanel.examples.stories.tsx Enhanced virtualization example with dynamic height measurement using measureElement, added test item with wrapping text, and removed debug flag
.changeset/dry-pets-appear.md Added changeset documenting the minor version change

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

</ActionList.Item>
)
}
})
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider adding a displayName to the MappedActionListItem component for better debugging experience in React DevTools. While it's an internal component, setting displayName is a best practice for forwardRef components in this codebase.

Example:

const MappedActionListItem = forwardRef<HTMLLIElement, ItemInput & {renderItem?: RenderItemFn}>((item, ref) => {
  // ... component implementation
})

MappedActionListItem.displayName = 'MappedActionListItem'
Suggested change
})
})
MappedActionListItem.displayName = 'MappedActionListItem'

Copilot uses AI. Check for mistakes.
@kendallgassner kendallgassner added this pull request to the merge queue Dec 2, 2025
Merged via the queue into main with commit 8e66a2c Dec 2, 2025
59 checks passed
@kendallgassner kendallgassner deleted the kendallg/allow-variable-height-on-virtualization branch December 2, 2025 03:15
@primer primer bot mentioned this pull request Dec 2, 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.

3 participants