Skip to content

Commit d85459e

Browse files
authored
stop using Dialog.showModal (#1872)
1 parent f97e1fa commit d85459e

File tree

1 file changed

+26
-33
lines changed

1 file changed

+26
-33
lines changed

src/ui/components/Modal.vue

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
11
<script setup lang="ts">
2-
import { useTemplateRef, Component as VueComponent, watch } from 'vue'
2+
import { Component as VueComponent } from 'vue'
33
4-
const props = defineProps<{
4+
defineProps<{
55
eoa?: string
66
modalClose?: () => void
77
isVisible: boolean
88
modalContent: VueComponent
99
attrs: { [key: string]: any }
1010
}>()
11-
12-
const dialog = useTemplateRef('dialog')
13-
14-
watch(props, () => {
15-
if (props.isVisible) {
16-
dialog.value?.showModal()
17-
} else {
18-
dialog.value?.close()
19-
}
20-
})
2111
</script>
2212

2313
<style>
@@ -43,25 +33,28 @@ html:has(dialog[open]) {
4333
</style>
4434

4535
<template>
46-
<dialog
47-
ref="dialog"
48-
class="fixed inset-0 flex items-center justify-center overflow-y-auto backdrop:bg-black/60"
49-
:class="{ hidden: !isVisible }"
50-
>
51-
<Transition>
52-
<div class="relative m-auto w-full py-4">
53-
<component
54-
:eoa="eoa"
55-
:modalClose="modalClose"
56-
v-show="isVisible"
57-
:is="modalContent"
58-
v-bind="attrs"
59-
>
60-
<template #after:description>
61-
<slot name="after:description" />
62-
</template>
63-
</component>
64-
</div>
65-
</Transition>
66-
</dialog>
36+
<Teleport to="body">
37+
<dialog
38+
class="fixed inset-0 flex items-center justify-center overflow-y-auto"
39+
v-show="isVisible"
40+
:open="isVisible"
41+
>
42+
<div class="fixed inset-0 bg-black/60"></div>
43+
<Transition>
44+
<div class="relative m-auto w-full py-4">
45+
<component
46+
:eoa="eoa"
47+
:modalClose="modalClose"
48+
v-show="isVisible"
49+
:is="modalContent"
50+
v-bind="attrs"
51+
>
52+
<template #after:description>
53+
<slot name="after:description" />
54+
</template>
55+
</component>
56+
</div>
57+
</Transition>
58+
</dialog>
59+
</Teleport>
6760
</template>

0 commit comments

Comments
 (0)