diff --git a/src/components/overlaypanel/OverlayPanel.vue b/src/components/overlaypanel/OverlayPanel.vue index 5001389ac..34f8ea552 100644 --- a/src/components/overlaypanel/OverlayPanel.vue +++ b/src/components/overlaypanel/OverlayPanel.vue @@ -13,6 +13,7 @@ import DomHandler from '../utils/DomHandler'; export default { props: { + appendTo: String, baseZIndex: { type: Number, default: 0 @@ -30,6 +31,7 @@ export default { target: null, outsideClickListener: null, beforeDestroy() { + this.restoreAppend(); this.unbindOutsideClickListener(); this.target = null; }, @@ -48,6 +50,7 @@ export default { this.visible = false; }, onEnter() { + this.appendContainer(); this.alignOverlay(); this.bindOutsideClickListener(); @@ -79,6 +82,22 @@ export default { }, isTargetClicked() { return this.target && (this.target === event.target || this.target.contains(event.target)); + }, + appendContainer() { + if (this.appendTo) { + if (this.appendTo === 'body') + document.body.appendChild(this.$refs.container); + else + document.getElementById(this.appendTo).appendChild(this.$refs.container); + } + }, + restoreAppend() { + if (this.$refs.container && this.appendTo) { + if (this.appendTo === 'body') + document.body.removeChild(this.$refs.container); + else + document.getElementById(this.appendTo).removeChild(this.$refs.container); + } } } } diff --git a/src/views/overlaypanel/OverlayPanelDemo.vue b/src/views/overlaypanel/OverlayPanelDemo.vue index 017b5c763..3e78f3ae6 100644 --- a/src/views/overlaypanel/OverlayPanelDemo.vue +++ b/src/views/overlaypanel/OverlayPanelDemo.vue @@ -10,7 +10,7 @@