Skip to content

Commit

Permalink
feat: add openOnMount option
Browse files Browse the repository at this point in the history
  • Loading branch information
wobsoriano committed Dec 2, 2022
1 parent b44a29a commit 13f65a2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/components/VueWinBox.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { PropType } from 'vue'
import { Teleport, defineComponent, h, onMounted, onUnmounted, ref } from 'vue'
import { Teleport, defineComponent, h, onMounted, onScopeDispose, ref } from 'vue'
import { nanoid } from 'nanoid'

declare const WinBox: WinBox.WinBoxConstructor
Expand All @@ -10,6 +10,10 @@ export const VueWinBox = defineComponent({
type: Object as PropType<WinBox.Params>,
required: true,
},
openOnMount: {
type: Boolean,
default: true,
},
},
emits: [
'move',
Expand Down Expand Up @@ -70,10 +74,13 @@ export const VueWinBox = defineComponent({
}

onMounted(() => {
if (!props.openOnMount)
return
initialize()
})

onUnmounted(() => {
onScopeDispose(() => {
// This causes errors like https://github.com/wobsoriano/vue-winbox/issues/10
winbox.value?.close()
})

Expand Down

0 comments on commit 13f65a2

Please sign in to comment.