Skip to content

Replace deprecated ref helper usage#7834

Merged
joshblack merged 6 commits into
mainfrom
copilot/remove-use-ref-object-as-forwarded-ref
May 14, 2026
Merged

Replace deprecated ref helper usage#7834
joshblack merged 6 commits into
mainfrom
copilot/remove-use-ref-object-as-forwarded-ref

Conversation

@joshblack
Copy link
Copy Markdown
Member

@joshblack joshblack commented May 12, 2026

Update usage our deprecated ref helper to use the new pattern for merging refs 🎉

Changelog

New

Changed

  • Update useRefObjectAsForwardedRef to useMergedRefs

Removed

Rollout strategy

  • None; if selected, include a brief description as to why

This is an internal refactor, functionality must be the same

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 12, 2026

⚠️ No Changeset found

Latest commit: 8234280

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions Bot added staff Author is a staff member integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels May 12, 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.

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

@github-actions github-actions Bot requested a deployment to storybook-preview-7834 May 12, 2026 14:27 Abandoned
@github-actions github-actions Bot temporarily deployed to storybook-preview-7834 May 12, 2026 14:38 Inactive
Copilot AI and others added 2 commits May 12, 2026 14:48
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
@joshblack
Copy link
Copy Markdown
Member Author

@copilot resolve the merge conflicts in this pull request

@joshblack joshblack added the skip changeset This change does not need a changelog label May 12, 2026
…f-object-as-forwarded-ref

# Conflicts:
#	packages/react/src/Heading/Heading.tsx

Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented May 12, 2026

@copilot resolve the merge conflicts in this pull request

Done — I merged origin/main into this branch and resolved the conflict in Heading.tsx in commit be2558736.

@joshblack joshblack marked this pull request as ready for review May 12, 2026 17:48
@joshblack joshblack requested a review from a team as a code owner May 12, 2026 17:48
@joshblack joshblack requested review from Copilot and siddharthkp May 12, 2026 17:48
Copy link
Copy Markdown
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 replaces deprecated useRefObjectAsForwardedRef usage with the newer useMergedRefs pattern across several components in @primer/react, preserving existing behavior while improving ref compatibility (notably with callback refs / React 19 ref cleanups).

Changes:

  • Swapped useRefObjectAsForwardedRef(...) + ref={internalRef} for const mergedRef = useMergedRefs(forwardedRef, internalRef) + ref={mergedRef} in multiple components.
  • Updated Overlay/PageLayout/Dialog and several UI primitives to consistently forward and retain internal refs via merged refs.
  • Adjusted an Autocomplete blur test to use deterministic fireEvent.blur + waitFor rather than userEvent.tab().
Show a summary per file
File Description
packages/react/src/TextInputWithTokens/TextInputWithTokens.tsx Use useMergedRefs to combine forwarded + internal input refs.
packages/react/src/PageLayout/PageLayout.tsx Merge forwarded refs with context-provided pane/sidebar refs.
packages/react/src/Overlay/Overlay.tsx Merge forwarded overlay ref with internal overlayRef.
packages/react/src/Link/Link.tsx Merge polymorphic forwarded ref with innerRef used for dev warnings.
packages/react/src/Heading/Heading.tsx Merge forwarded ref with internal heading ref.
packages/react/src/Dialog/Dialog.tsx Merge forwarded dialog ref with internal dialogRef.
packages/react/src/deprecated/DialogV1/Dialog.tsx Replace deprecated ref helper with merged refs in v1 dialog.
packages/react/src/Button/ButtonBase.tsx Merge forwarded ref with internal button ref while preserving internal access.
packages/react/src/Autocomplete/AutocompleteOverlay.tsx Merge scrollContainerRef and anchored-position floatingElementRef into Overlay ref.
packages/react/src/Autocomplete/AutocompleteInput.tsx Merge forwarded ref with context inputRef.
packages/react/src/Autocomplete/Autocomplete.test.tsx Make blur/close assertion deterministic in browser-mode Vitest.
packages/react/src/ActionList/Heading.tsx Merge forwarded ref with internal heading ref passed to Heading component.
packages/react/src/ActionBar/ActionBar.tsx Merge forwarded ref with internal IconButton ref.

Copilot's findings

  • Files reviewed: 13/13 changed files
  • Comments generated: 0

@joshblack joshblack added the Canary Release Apply this label when you want CI to create a canary release of the current PR label May 13, 2026
@primer-integration
Copy link
Copy Markdown

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

@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!

@joshblack joshblack added this pull request to the merge queue May 14, 2026
Merged via the queue into main with commit d3c8fe2 May 14, 2026
62 of 63 checks passed
@joshblack joshblack deleted the copilot/remove-use-ref-object-as-forwarded-ref branch May 14, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Canary Release Apply this label when you want CI to create a canary release of the current PR integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm skip changeset This change does not need a changelog staff Author is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants