visx icon indicating copy to clipboard operation
visx copied to clipboard

feat(tooltip): Enable custom portal container for tooltip

Open fbouquet opened this issue 3 years ago β€’ 12 comments

:rocket: Enhancements

  • Enables setting a custom container for the tooltip portal when using useTooltipInPortal, via the portalContainer property.

Currently, when using useTooltipInPortal, the tooltip renders at the root of the document. My team is running into an issue where we are sometimes rendering a dropdown in a static tooltip, but the dropdown menu appears behind the tooltip. Setting hacky z indexes would not robustly fix the issue if there is another overlay layer that is supposed to be under the tooltip, and we figured that if we could tell the tooltip portal where to render, we could fix the bug in a clean way.

I've updated the tooltip example to show that use case:

https://user-images.githubusercontent.com/6173255/190206148-c73b224d-9937-4c33-af4d-9779ca4a8fa3.mov

https://user-images.githubusercontent.com/6173255/190206164-970cc2c9-01dd-4d72-984a-1b34b3b6cddc.mov

fbouquet avatar Sep 14 '22 16:09 fbouquet

happo diff looks good (sorry this isn't visible to contributors) image

williaster avatar Sep 16 '22 18:09 williaster

Thanks a lot for the quick code review @williaster !

I went ahead and updated the code based on your comments. I'll be away from keyboard for the next two weeks but if there's anything else that need to be changed I'll be happy to look into it when I'm back.

fbouquet avatar Sep 16 '22 22:09 fbouquet

Hi @williaster ! Just wanted to double check if there's anything else needed from me on this PR or if it's all good to go?

fbouquet avatar Oct 04 '22 19:10 fbouquet

Hey @fbouquet thanks again for the addition and your patience getting this in. I have one big concern with this as it stands.

Hi @williaster ! Thank you, those are good points, I'll be looking into this within the next 2 weeks and will get back to you. πŸ™‚

fbouquet avatar Oct 12 '22 18:10 fbouquet

@williaster Apologies for the additional delay on this, the last few weeks have been busier than I had expected. I went ahead and updated my code to correctly handle container changes in position and size, and I also fixed the TooltipWithBounds case when a custom portal is specified.

Unfortunately that behavior is hard to cover in automated tests but I was able to manually ensure that things are working well with my changes, as you can see in the screen recording above. πŸ™‚

fbouquet avatar Nov 10 '22 20:11 fbouquet

Hi @williaster ! πŸ‘‹ Just wanted to send you a reminder about this PR; anything I should change before it's ready to go?

fbouquet avatar Nov 29 '22 16:11 fbouquet

Thank you for the code review @williaster and apologies for the long delay of my response, the end of year has been pretty busy. I'll be dealing with your comments in the near future and will ping you when it's ready for another round. πŸ™‚

fbouquet avatar Jan 18 '23 16:01 fbouquet

Sounds great @fbouquet ! Will keep an eye out for your ping when you have time πŸ‘

williaster avatar Jan 18 '23 20:01 williaster

@williaster I requested a new review last week but just realized I didn't ping you, so I'm doing that now to make sure that you see the notification. No big rush though!

fbouquet avatar Jan 25 '23 16:01 fbouquet

@williaster Just a reminder about this PR for whenever you get a chance to look into it. πŸ™‚

fbouquet avatar Mar 02 '23 21:03 fbouquet

Ran into an issue today with tooltips in portals due to the fact that we're using Tailwind with the important config option set to the __next div, so TooltipInPortal is unable to be styled by Tailwind due to the fact that the portal is rendering in the root of the DOM. Would love to simply be able to specify a selector for the hook to use in the Portal, similar to what's done here: https://github.com/vercel/next.js/blob/canary/examples/with-portals/components/ClientOnlyPortal.js. Came across this PR, looks like it's been stale for a while though, any plans for it to be merged soon or was it handled by a different update since the last comment?

TSIA-SN avatar Nov 22 '23 14:11 TSIA-SN