Skip to content

Tooltip breaks ref forwarding on wrapped element #8373

Description

@iansan5653

Description

If you wrap an element like Button in Tooltip, the ref of that button will be discarded and ignored. This breaks ref-based functionality like returning focus. The only way to get a ref to the underlying element is to set ref on the tooltip itself, but that's very unintuitive and subtle.

Steps to reproduce

<Tooltip ref={(element) => console.log("Tooltip ref", element)} text="Tooltip text">
  <Button ref={(element) => console.log("Button ref", element)}>Button text</Button>
</Tooltip>

The resulting log when rendering this code will be:

Tooltip ref, HTMLButtonElement

Notice that Button ref never appears in the logs.

Version

v38.37.0

Browser

No response

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions