Skip to content
This repository was archived by the owner on Dec 19, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion iron-overlay-backdrop.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ interface IronOverlayBackdropElement extends Polymer.Element {
/**
* Appends the backdrop to document body if needed.
*/
prepare(): void;
prepare(parentNode?: Node|null): void;

/**
* Shows the backdrop.
Expand Down
12 changes: 7 additions & 5 deletions iron-overlay-backdrop.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,12 @@

/**
* Appends the backdrop to document body if needed.
* @param {Node=} parentNode
*/
prepare: function() {
if (this.opened && !this.parentNode) {
Polymer.dom(document.body).appendChild(this);
prepare: function(parentNode) {
parentNode = parentNode || document.body;
if (this.opened && parentNode !== this.parentNode) {
Polymer.dom(parentNode).appendChild(this);
}
},

Expand Down Expand Up @@ -131,8 +133,8 @@
*/
_openedChanged: function(opened) {
if (opened) {
// Auto-attach.
this.prepare();
// Auto-attach, keep current parent.
this.prepare(this.parentNode);
} else {
// Animation might be disabled via the mixin or opacity custom property.
// If it is disabled in other ways, it's up to the user to call complete.
Expand Down
18 changes: 14 additions & 4 deletions iron-overlay-manager.html
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,20 @@
}
this.backdropElement.style.zIndex = this._getZ(overlay) - 1;
this.backdropElement.opened = !!overlay;
// Property observers are not fired until element is attached
// in Polymer 2.x, so we ensure element is attached if needed.
// https://github.com/Polymer/polymer/issues/4526
this.backdropElement.prepare();
// Insert the backdropElement in the dialog with backdrop below it
// in order to support nested overlays.
if (overlay) {
var parentOverlay = null;
for (var i = this._overlays.length - 1; i >= 0; i--) {
var candidate = this._overlays[i];
if (candidate !== overlay && candidate.withBackdrop &&
Polymer.dom(candidate).deepContains(overlay)) {
parentOverlay = candidate;
break;
}
}
this.backdropElement.prepare(parentOverlay);
}
},

/**
Expand Down