Polymer 1.x:paper-dialog模式出现在app-header-layout后面

时间:2016-10-01 04:40:46

标签: polymer polymer-1.0 paper-elements plunker app-elements

我想将一个子元素(子元素)放在app-header-layout中。子元素包含paper-dialog modal。当我打开模态时,我希望看到对话框出现在背景的前面中。相反,对话框背景下显示。

Modal appears behind backdrop

如何让模态对话框出现在背景幕前?或者这可能是app-drawer-layoutapp-header-layout元素中新发现的错误?

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>
内容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 个答案:

答案 0 :(得分:2)

这是众所周知的(请参阅thisthis github问题),但遗憾的是paper-dialog使用的iron-overlay-behavior没有明确记录的限制:

  

您必须确保没有元素具有更高的堆叠上下文   z-index比其父堆栈上下文。你应该放置它   尽可能让孩子成为孩子。

一种解决方法是将paper-dialog移到content-el之外以及app-header-layout之外(移至index.html或作为您的根的直接子项{ {1}}元素)。您可以触发事件(即my-app并在根元素中处理该事件。)