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.

Portalled tooltips appear behind modals/overlays that have z-index

See original GitHub issue

Bug report

Using a portalled tooltip in an overlay or modal that has a z-index means the tooltip gets positioned behind the modal.

Current Behavior

Portalled tooltips are placed at end of <body> with <radix-portal> element and a <div> with positioning. These cannot be styled specifically for tooltip instances and therefore can’t have z-index set on them. So they can’t appear above any item that created them that has a z-index.

To attempt to fix I set the tooltip portalled to false, but this also illustrates the problem from this issue where a not portalled tooltip inside a positioned element such as a modal will not be positioned correctly:

Screen Shot 2020-12-23 at 1 23 20 PM

Expected behavior

Portalled tooltips appear above the elements that create them and/or can have a z-index set on them and are positioned correctly.

Reproducible example

CodeSandbox

Suggested solution

Give the positioning div a [radix] attribute to allow styling with a z-index.

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
  • Comments:9

github_iconTop GitHub Comments

1reaction
benoitgrelardcommented, Jan 29, 2021

Hey @mattaningram, just a heads up in case you are still depending on the radix-portal selector as a hack (and haven’t moved to the new selector), we are introducing some change to our Portal which should actually negate all these hacks in the first place. See #410 for more context.

1reaction
mattaningramcommented, Jan 4, 2021

That would be perfect!

In the short term I’m using the radix-portal > div { z-index: … } approach, and in long term going to remove the z-index from my non-Radix modal/overlay components to address issue overall (since you are right that ideally they shouldn’t need them).

Adding those additional data-radix-* attributes will allow people to fix this issue if they can’t fix their modals.

Thank you! Looking forward to getting more Radix primitives into our codebase soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bootstrap tooltip showing behind modal window
Just do one thing. Check the z-index of your modal popup & set the tooltip z-index + ...
Read more >
Z-index · Bootstrap v5.2
We utilize a default z-index scale in Bootstrap that's been designed to properly layer navigation, tooltips and popovers, modals, and more. These higher...
Read more >
Tooltip appears behind Modal window · Issue #439 - GitHub
Using a Tooltip on a Modal window causes the Tooltip to appear behind the Modal. It seems like the default z-index for Tooltips...
Read more >
Using React Portals to build a modal - LogRocket Blog
Learn how to build a modal or overlay component in React with React Portals. Our demo is applicable for all top level components....
Read more >
Portals - React
Portals provide a first-class way to render children into a DOM node that ... case for portals is when a parent component has...
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