question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tooltip position incorrect when portalled = false inside positioned parent container

See original GitHub issue

Bug report

Current Behavior

With the default portalled behavior the tooltip appears in the correct position:

Screen Shot 2020-12-23 at 11 21 24 AM

With portalled set to false the tooltip wrapping div does appear in the correct place in the DOM, but it has a large translate3d value set to it meaning it is not visible. This translate3d value is the same as the portalled version meaning its calculating from the corner of the screen.

Screen Shot 2020-12-23 at 11 24 11 AM

If I remove the translate3d from the wrapper, the tooltip is visible, but still in the wrong position:

Screen Shot 2020-12-23 at 11 27 00 AM

Expected behavior

Visual position of tooltip should be the same for both portalled and not portalled. The tooltip being positioned needs to know if positioning is relative to screen or a parent container with a position set.

Reproducible example

CodeSandbox Example

Suggested solution

Update positioning logic to take into account parent containers which change 0, 0 position.

Your environment

Software Name(s) Version
Radix Package(s) Tooltip 0.01
React n/a 16.12
Browser Chrome, FF, Safari, Edge Latest
Assistive tech n/a
Node n/a 10.17
npm/yarn Yarn 1.22.10
Operating System Mac + Windows Latest

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8

github_iconTop GitHub Comments

3reactions
mattaningramcommented, Jan 4, 2021

I can only use the portalled version if we can control the z-index of the content in the radix-portal, otherwise the tooltips appear behind my modals and overlays which are also portalled but have a z-index that we can’t remove yet: https://github.com/radix-ui/primitives/issues/368

I would perhaps note this in documentation until it is fixed because having a tooltip in a scrollable/positioned parent is very common, so if you allow for turning portalling off a lot of people will encounter this bug.

1reaction
benoitgrelardcommented, Jan 8, 2021

The pointer-events thing can be controlled via a prop: disableOutsidePointerEvents. You can turn that off if you don’t want/need it. It is there to block interactions when clicking outside do dismiss the menu.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tooltip in a parent container is in wrong position if ... - GitHub
What is the expected behavior? The tooltip should be positioned close to the text paragraph, and not be affected by the scroll position...
Read more >
CSS: Why are my tooltips getting positioned incorrectly?
Approach 1. following the OP's code without any changes. Issue. The issue is that position absolute and bottom are on different elements and ......
Read more >
Tooltips - Bootstrap
Tooltip position attempts to automatically change when a parent container has overflow: auto or overflow: scroll like our .table-responsive , but still ...
Read more >
Positioning - Angular powered Bootstrap
Tooltip ; Typeahead. When the popup is opened, it is positioned correctly next to the target element and fits in the viewport.
Read more >
Chart - wrong tooltip position when inside a SVG element
In this example, the parent element of the SVG element uses the viewBox. This leads to translation of coordinates. Currently, matrix coordinate ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found