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

Expose a stack of Top Layer elements #2525

Closed
valdrinkoshi opened this issue Apr 12, 2017 · 7 comments
Closed

Expose a stack of Top Layer elements #2525

valdrinkoshi opened this issue Apr 12, 2017 · 7 comments

Comments

@valdrinkoshi
Copy link

Building custom overlays is hard, especially because of how stacking context works - more context here https://github.com/PolymerLabs/iron-overlay#the-problem

Delegating to the end user the responsibility of declaring overlays in a stacking-context-safe parent node is not viable for Custom Elements authors and users, as they would have to trade encapsulation to solve this issue.

We need an API to explain the magic of the <dialog>, specifically why it is not affected by the stacking context trap.

Proposed solutions:

  • css property position: top-layer
  • stack of Top Layer elements (similar to the proposed Blocking Elements stack) e.g.
document.topLayerElements.push(element);
document.topLayerElements.pop();
document.topLayerElements.remove(element);
document.topLayerElements.top;

@alice @domenic WDYT?

@domenic
Copy link
Member

domenic commented Apr 12, 2017

Dupe of #897, modulo #2341 :)

@valdrinkoshi
Copy link
Author

@domenic how is this a dupe of #897?
My understanding is that Blocking Elements stack ensures no other element is interactive, except the current blocking element. The problem exposed here is that custom elements don't have a way to register as top layer elements.
e.g. http://jsbin.com/kuboqa/1/edit?html,output

<style>
  .backdrop {
    position: fixed;
    top: 0; bottom: 0;
    left: 0; right: 0;
    z-index: 1;
    background-color: rgba(0, 0, 0, 0.5);
  }
  .overlay {
    position: fixed;
    z-index: 2;
  }
</style>

<div class="backdrop"></div>

<!-- this creates a new stacking context -->
<div style="transform: translateZ(0);">
  <div class="overlay">
    <button>click me!</button>
  </div>
</div>

^ you cannot click the button in .overlay because stacking context

@domenic
Copy link
Member

domenic commented Apr 12, 2017

I'm confused now. Are you talking about top layer (the subject of #897) or stacking contexts? They are completely different and unrelated things.

@valdrinkoshi
Copy link
Author

For the way I see it, being in the Top Layer has two perks:

  1. users cannot interact with any other part of the document
  2. elements in the Top Layer are subject to the Top Layer's stacking context - aka rendered on top of everything else even if they're declared inside an element that creates new stacking context

#897 addresses only 1), right?

@domenic
Copy link
Member

domenic commented Apr 12, 2017

No, #897 is about putting things in the top layer, period. It's not about some kind of half-top-layer feature, it's about the actual top layer.

@valdrinkoshi
Copy link
Author

Good to know, thanks for clarifying 👍
It wasn't immediately clear that Blocking Elements === Top Layer Elements.

@domenic
Copy link
Member

domenic commented Apr 12, 2017

Yep, that's the "modulo #2341" part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants