Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tooltip stops working when passing ref to overlay #305

Closed
gndelia opened this issue Mar 15, 2022 · 1 comment
Closed

Tooltip stops working when passing ref to overlay #305

gndelia opened this issue Mar 15, 2022 · 1 comment

Comments

@gndelia
Copy link

gndelia commented Mar 15, 2022

I have an overlay, say

const overlay = <div>content</div>

if I use it as-is, it works

<Tooltip
  overlay={overlay}
  trigger={['hover']}
>
  <span>Hover me!</span>
</Tooltip>

However, if passing a ref to the overlay, it stops working (overlay does not render)

// assuming overlay comes as a variable prop from somewhere else
const ref = useRef(null)
<Tooltip
  overlay={<div ref={ref}>{overlay}</div>}
  trigger={['hover']}
>
  <span>Hover me!</span>
</Tooltip>

This is a simplification of the issue I'm currently having. Just removing the ref like this

// assuming overlay comes as a variable prop from somewhere else
<Tooltip
  overlay={<div>{overlay}</div>}
  trigger={['hover']}
>
  <span>Hover me!</span>
</Tooltip>

works

@gndelia
Copy link
Author

gndelia commented Mar 15, 2022

I think I can close this issue. The problem was that there was an event that was fired once the overlay was rendering, that was forcing the tooltip to disable. It was related to facebook/react#20636 and facebook/react#20863 - I wasn't expecting the events to be fired at the same moment they were rendering, so that's why I thought it was a problem on the tooltip. Closing!

@gndelia gndelia closed this as completed Mar 15, 2022
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

No branches or pull requests

1 participant