Popper-core: How to manage z-index issues?

Created on 2 Nov 2017  ·  8Comments  ·  Source: popperjs/popper-core

CodePen demo

https://codepen.io/sontek/pen/OOMmvN

Steps to reproduce the problem

The popper is below both the content and the absolute positioned footer. How can I make sure it is above them?

What is the expected behavior?

The popper to be above the absolute positioned footer.

What went wrong?

The popper is below it.

# QUESTION ❔

Most helpful comment

So basically popper.js eschews the problem of browsers missing a global z-index (*), which is the main reason for positioning popups in js in the first place. I kept wondering "how does popper keep the popups on top of everything if it doesn't move them to the root element, since there might be implicit z-stacks created along the path?" Now I know: it doesn't.

(*) Let's face it, stacking contexts are just an abstraction leak of the graphics model. Saying "create shallow context stacks" is not helpful as there's plenty of legit use cases that create implicit z-stacks.

All 8 comments

https://codepen.io/FezVrasta/pen/QOyvVg ?

The thing is, any z-index higher than 3 denotes a lack of understanding of how it works.

@FezVrasta Sorry, we have z-index higher than 3 because we use an opensource react component that has set their z-index higher than that and we have to pop above it.

Your pen gets it above the content but not the absolute positioned footer, which is my problem. Shrink your window so the gray box is closer to the popper

isolation: isolate is your best friend.

z-index is thought to be used in "stack contexts", you just create small stacks with few elements (and then, few layers)

@FezVrasta Yeah, but isolation isn't supported in any IE (even modern ones), correct?

So what would be the best way to handle a thing like what I'm doing here? In the codepen you posted its just z-index: 1 and z-index: 2 but the popper doesn't go above the absolute positioned element that has the lower z-index.

You want to have a stacking context for the page layout, and then on top of it you put a other elements (like the popper) that with just a z-index: 1 will stay above the rest

So basically popper.js eschews the problem of browsers missing a global z-index (*), which is the main reason for positioning popups in js in the first place. I kept wondering "how does popper keep the popups on top of everything if it doesn't move them to the root element, since there might be implicit z-stacks created along the path?" Now I know: it doesn't.

(*) Let's face it, stacking contexts are just an abstraction leak of the graphics model. Saying "create shallow context stacks" is not helpful as there's plenty of legit use cases that create implicit z-stacks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FezVrasta picture FezVrasta  ·  5Comments

cixonline picture cixonline  ·  5Comments

DawnWright picture DawnWright  ·  4Comments

kerf007 picture kerf007  ·  3Comments

FezVrasta picture FezVrasta  ·  3Comments