Skip to content

Commit be20a8d

Browse files
committed
Revert "stop using Dialog.showModal (#1872)"
This reverts commit d85459e.
1 parent e0403c4 commit be20a8d

File tree

1 file changed

+33
-26
lines changed

1 file changed

+33
-26
lines changed

src/ui/components/Modal.vue

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
<script setup lang="ts">
2-
import { Component as VueComponent } from 'vue'
2+
import { useTemplateRef, Component as VueComponent, watch } from 'vue'
33
4-
defineProps<{
4+
const props = 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+
})
1121
</script>
1222

1323
<style>
@@ -33,28 +43,25 @@ html:has(dialog[open]) {
3343
</style>
3444

3545
<template>
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>
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>
6067
</template>

0 commit comments

Comments
 (0)