Skip to content

fix(popper): allow virtualRef to accept RefObject<Measurable | null> for React 19#3969

Open
patrickwehbe wants to merge 1 commit into
radix-ui:mainfrom
patrickwehbe:fix/popper-virtualref-null-react19
Open

fix(popper): allow virtualRef to accept RefObject<Measurable | null> for React 19#3969
patrickwehbe wants to merge 1 commit into
radix-ui:mainfrom
patrickwehbe:fix/popper-virtualref-null-react19

Conversation

@patrickwehbe

Copy link
Copy Markdown

Description

PopperAnchor's virtualRef prop is typed as React.RefObject<Measurable>, but in React 19 useRef<Measurable>(null) returns RefObject<Measurable | null>. As a result, passing a virtual ref (the documented anchoring pattern) fails to type-check under React 19.

This widens the prop type to React.RefObject<Measurable | null>. The change is type-only and internally safe:

  • anchorRef is already Measurable | null (useRef<Measurable | null>(null)).
  • virtualRef.current is read into that slot, and rendering only branches on virtualRef truthiness.

No runtime behavior changes, and existing callers passing a non-null ref remain assignable.

Closes #3635

@changeset-bot

changeset-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e49b93e

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

This PR includes changesets to release 10 packages
Name Type
@radix-ui/react-popper Patch
@radix-ui/react-hover-card Patch
@radix-ui/react-menu Patch
@radix-ui/react-popover Patch
radix-ui Patch
@radix-ui/react-select Patch
@radix-ui/react-tooltip Patch
@radix-ui/react-context-menu Patch
@radix-ui/react-dropdown-menu Patch
@radix-ui/react-menubar Patch

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@radix-ui/popover: Cannot use anchorRef in React 19

1 participant