Polymer 1.x: paper-dialog modal appears behind app-header-layout

纵饮孤独 提交于 2019-12-24 02:07:19

问题


I want to put a sub-element (child) inside an app-header-layout. The sub-element contains a paper-dialog modal. When I open the modal I expect to see the dialog box appear in front of the backdrop. Instead, the dialog appears behind the backdrop.

How do I get the modal dialog to appear in front of the backdrop? Or is this perhaps a newly discovered bug in the app-drawer-layout or app-header-layout elements?

Here is the plunk. ... http://plnkr.co/edit/ZjPHGqkt8vvDbFdF4CNn?p=preview

index.html
<!DOCTYPE html>
<html lang="en">
  <head>
    <link rel="import" href="x-app.html">
  </head>
  <body>
    <x-app></x-app>
  </body>
</html>
x-app.html
<link href="content-el.html" rel="import">

<base href="https://polygit.org/components/">

<script src="webcomponentsjs/webcomponents-lite.min.js"></script>
<link href="polymer/polymer.html" rel="import">

<link href="app-layout/app-drawer/app-drawer.html" rel="import">
<link href="app-layout/app-drawer-layout/app-drawer-layout.html" rel="import">
<link href="app-layout/app-header-layout/app-header-layout.html" rel="import">
<link href="app-layout/app-header/app-header.html" rel="import">
<link href="app-layout/app-toolbar/app-toolbar.html" rel="import">

<link href="iron-icon/iron-icon.html" rel="import">
<link href="iron-icons/iron-icons.html" rel="import">
<link href="paper-icon-button/paper-icon-button.html" rel="import">

<dom-module id="x-app">

<template>

  <style></style>

  <app-drawer-layout>
    <app-drawer>
      drawer-content
    </app-drawer>
    <app-header-layout>
      <app-header>
        <app-toolbar>
          <paper-icon-button icon="menu" drawer-toggle></paper-icon-button>
          <div main-title>MyNewApp</div>
        </app-toolbar>
      </app-header>

      <content-el></content-el>

    </app-header-layout>
  </app-drawer-layout>

</template>

<script>
  (function(){
    Polymer({
      is: 'x-app',
      properties: {},
    });
  })();
</script>

</dom-module>
content-el.html
<base href="https://polygit.org/components/">
<script src="webcomponentsjs/webcomponents-lite.min.js"></script>
<link href="polymer/polymer.html" rel="import">

<link href="paper-dialog/paper-dialog.html" rel="import">

<dom-module id="content-el">

  <template>
    <button on-tap="show">Click to show dialog</button>
    <paper-dialog id="dialog" modal>
      <h2>Header</h2>
      <div>Dialog body</div>
    </paper-dialog>
  </template>

  <script>
    (function(){
      Polymer({
        is: 'content-el',
        properties: {},
        show: function() {
          this.$.dialog.open();
        },
      });
    })();
  </script>

</dom-module>

回答1:


This is a known (see this and this github issue) but unfortunately not very well documented limitations of the iron-overlay-behavior, that is used by paper-dialog:

You must ensure no element has a stacking context with a higher z-index than its parent stacking context. You should place this element as a child of whenever possible.

One workaround is to move the paper-dialog outside of the content-el and also outside of theapp-header-layout (either into the index.html or as a direct child of your root my-app element). You can fire an event (i.e. open-dialog and handle that in your root element).



来源:https://stackoverflow.com/questions/39803097/polymer-1-x-paper-dialog-modal-appears-behind-app-header-layout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!