Skip to content

Commit 6d7b207

Browse files
committed
set attach prop default to false, bugfix attach equal false
1 parent 6f3dd52 commit 6d7b207

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export default {
9292
| overlayClass | String | --- | '' | Add classes to the overlay element. |
9393
| transition | String | --- | 'vfm' | CSS transition applied to the modal window. |
9494
| overlayTransition | String | --- | 'vfm' | CSS transition applied to the overlay (background). |
95-
| attach | any | --- | false | Specifies which DOM element that this component should detach to. String can be any valid querySelector and Object can be any valid Node. |
95+
| attach | any | --- | 'body' | Specifies which DOM element that this component should detach to. Set `false` will disabled this feature. String can be any valid querySelector and Object can be any valid Node. Component will attach to the <body> element by default.
9696

9797
### Slots
9898

docs/components/global/BaseExample.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
:hide-overlay="false"
1212
:click-to-close="true"
1313
:prevent-click="false"
14-
:attach="false"
14+
attach="body"
1515
:z-index="1000"
1616
>
1717
<span class="text-2xl mb-2">Hello, world!</span>
@@ -30,6 +30,6 @@ export default {
3030

3131
<style lang="scss" scoped>
3232
::v-deep .overlay {
33-
opacity: 0.5;
33+
background-color: rgba(0, 0, 0, 0.5);
3434
}
3535
</style>

docs/content/en/properties.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,14 @@ The click event will not be blocked by overlay.
7979
## `attach`
8080

8181
- Type: `Any`
82-
- Default: `false`
82+
- Default: `body`
8383

8484
Specifies which DOM element that this component should detach to.
8585

86-
1. String can be any valid `querySelector`.
87-
2. Object can be any valid `Node`.
86+
1. By default, the modal will be attached to the `<body>` element.
87+
2. Set `false` will disabled this feature.
88+
3. String can be any valid `querySelector`
89+
4. Object can be any valid `Node`.
8890

8991
## `zIndex`
9092

@@ -111,7 +113,7 @@ Set `z-index` to both of the modal container and overlay elements.
111113
:hide-overlay="false"
112114
:click-to-close="true"
113115
:prevent-click="false"
114-
:attach="false"
116+
attach="body"
115117
:z-index="1000"
116118
>
117119
<span class="text-2xl mb-2">Hello, world!</span>

lib/VueFinalModal.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export default {
8787
clickToClose: { type: Boolean, default: true },
8888
preventClick: { type: Boolean, default: false },
8989
overlayClass: { type: String, default: '' },
90-
attach: { type: null, default: false, validator: validateAttachTarget },
90+
attach: { type: null, default: 'body', validator: validateAttachTarget },
9191
transition: { type: String, default: 'vfm' },
9292
overlayTransition: { type: String, default: 'vfm' },
9393
zIndex: { type: [String, Number], default: 1000 }
@@ -141,8 +141,8 @@ export default {
141141
mounted(value) {
142142
if (value) {
143143
let target = this.getAttachElement()
144-
if (target) {
145-
target.appendChild(this.$el)
144+
if (target || this.attach === false) {
145+
this.attach !== false && target.appendChild(this.$el)
146146
let index = modalStack.findIndex(vm => vm === this)
147147
if (index !== -1) {
148148
// if this is already exist in modalStack, delete it

0 commit comments

Comments
 (0)