Polymer 1.x: paper-dialog 模态出现在 app-header-layout 后面
Polymer 1.x: paper-dialog modal appears behind app-header-layout
我想把 sub-element (child) 放在 app-header-layout
里面。 sub-element 包含一个 paper-dialog modal
。当我打开模式时,我希望看到对话框出现在背景的 front 中。相反,对话框出现在背景 后面。
如何让模态对话框出现在背景前?或者这可能是 app-drawer-layout
或 app-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>
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>
这是已知的(参见 this and this github issue) but unfortunately not very well documented limitations of the iron-overlay-behavior,被 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.
一种解决方法是将 paper-dialog
移到 content-el
之外,也移到 app-header-layout
之外(移入 index.html
或作为您的直接子项根 my-app
元素)。您可以触发一个事件(即 open-dialog
并在您的根元素中处理它)。
我想把 sub-element (child) 放在 app-header-layout
里面。 sub-element 包含一个 paper-dialog modal
。当我打开模式时,我希望看到对话框出现在背景的 front 中。相反,对话框出现在背景 后面。
如何让模态对话框出现在背景前?或者这可能是 app-drawer-layout
或 app-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>
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>
这是已知的(参见 this and this github issue) but unfortunately not very well documented limitations of the iron-overlay-behavior,被 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.
一种解决方法是将 paper-dialog
移到 content-el
之外,也移到 app-header-layout
之外(移入 index.html
或作为您的直接子项根 my-app
元素)。您可以触发一个事件(即 open-dialog
并在您的根元素中处理它)。