Skip to content

Commit

Permalink
Add a container property to popup components
Browse files Browse the repository at this point in the history
Added container property for Modal, AppSettingsDialog, EmojiPicker and
the menu of the Avatar component.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
  • Loading branch information
PVince81 committed Mar 2, 2021
1 parent 6912b7a commit 9f51262
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 @@ -274,6 +275,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 9f51262

Please sign in to comment.