Skip to content

Commit

Permalink
Merge pull request #1734 from nextcloud/enh/noid/popups-add-container…
Browse files Browse the repository at this point in the history
…-property

Add a container property to popup components
  • Loading branch information
PVince81 authored Mar 3, 2021
2 parents d6e59a0 + 9f51262 commit 424657b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/components/AppSettingsDialog/AppSettingsDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ export default {
type: Boolean,
default: false,
},
/**
* Selector for the popover container
*/
container: {
type: String,
default: 'body',
},
},
data() {
Expand Down Expand Up @@ -244,6 +252,9 @@ export default {
// Return value of the render function
if (this.open) {
return createElement('Modal', {
attrs: {
container: this.container,
},
on: {
close: () => { this.handleCloseModal() },
},
Expand Down
9 changes: 9 additions & 0 deletions src/components/Avatar/Avatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<Popover
v-if="hasMenu"
placement="auto"
:container="menuContainer"
:open="contactsMenuOpenState">
<PopoverMenu :menu="menu" />
<template slot="trigger">
Expand Down Expand Up @@ -283,6 +284,14 @@ export default {
type: String,
default: 'center',
},
/**
* Selector for the popover menu container
*/
menuContainer: {
type: String,
default: 'body',
},
},
data() {
return {
Expand Down
9 changes: 9 additions & 0 deletions src/components/EmojiPicker/EmojiPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
<template>
<Popover
:open.sync="open"
:container="container"
popover-class="emoji-popover"
popover-inner-class="popover-emoji-picker-inner">
<template #trigger>
Expand Down Expand Up @@ -159,6 +160,14 @@ export default {
type: Boolean,
default: true,
},
/**
* Selector for the popover container
*/
container: {
type: String,
default: 'body',
},
},
data() {
return {
Expand Down
18 changes: 16 additions & 2 deletions src/components/Modal/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,14 @@ export default {
type: Boolean,
default: false,
},
/**
* Selector for the modal container
*/
container: {
type: String,
default: 'body',
},
},
data() {
Expand Down Expand Up @@ -338,8 +346,14 @@ export default {
this.handleSwipe(e)
})
// force mount the component to body
document.body.insertBefore(this.$el, document.body.lastChild)
if (this.container === 'body') {
// force mount the component to body
document.body.insertBefore(this.$el, document.body.lastChild)
} else {
const container = document.querySelector(this.container)
container.appendChild(this.$el)
}
},
destroyed() {
this.$el.remove()
Expand Down

0 comments on commit 424657b

Please sign in to comment.