Skip to content

Commit fc2c89f

Browse files
committed
feat: 更新 FaDrawer 和 FaModal 组件,强制关闭自带遮罩
1 parent 5ba6d08 commit fc2c89f

4 files changed

Lines changed: 24 additions & 6 deletions

File tree

packages/components/src/drawer/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ function handleAnimationEnd() {
178178
</script>
179179

180180
<template>
181-
<Sheet :open="isOpen" @update:open="updateOpen">
181+
<Sheet :modal="false" :open="isOpen" @update:open="updateOpen">
182182
<SheetContent
183183
ref="sheetContentRef"
184184
:drawer-id="drawerId"

packages/components/src/drawer/sheet/SheetContent.vue

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
22
import type { DialogContentEmits, DialogContentProps } from 'reka-ui'
33
import type { HTMLAttributes } from 'vue'
4-
import { reactiveOmit } from '@vueuse/core'
4+
import { reactiveOmit, useScrollLock } from '@vueuse/core'
55
import { X } from 'lucide-vue-next'
66
import {
77
DialogClose,
@@ -45,6 +45,15 @@ defineExpose({
4545
})
4646
4747
const showOverlay = computed(() => props.open && props.overlay)
48+
const isLocked = useScrollLock(document.body)
49+
watch(showOverlay, (val) => {
50+
if (val) {
51+
isLocked.value = true
52+
}
53+
else {
54+
isLocked.value = false
55+
}
56+
})
4857
</script>
4958

5059
<template>
@@ -71,7 +80,7 @@ const showOverlay = computed(() => props.open && props.overlay)
7180
}"
7281
/>
7382
</Transition>
74-
<SheetOverlay class="hidden" />
83+
<SheetOverlay />
7584
<DialogContent
7685
ref="sheetContentRef"
7786
data-slot="sheet-content"

packages/components/src/modal/dialog/DialogContent.vue

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
22
import type { DialogContentEmits, DialogContentProps } from 'reka-ui'
33
import type { HTMLAttributes } from 'vue'
4-
import { reactiveOmit } from '@vueuse/core'
4+
import { reactiveOmit, useScrollLock } from '@vueuse/core'
55
import { Maximize, Minimize, X } from 'lucide-vue-next'
66
import {
77
DialogClose,
@@ -47,6 +47,15 @@ defineExpose({
4747
})
4848
4949
const showOverlay = computed(() => props.open && props.overlay)
50+
const isLocked = useScrollLock(document.body)
51+
watch(showOverlay, (val) => {
52+
if (val) {
53+
isLocked.value = true
54+
}
55+
else {
56+
isLocked.value = false
57+
}
58+
})
5059
</script>
5160

5261
<template>
@@ -73,7 +82,7 @@ const showOverlay = computed(() => props.open && props.overlay)
7382
}"
7483
/>
7584
</Transition>
76-
<DialogOverlay class="hidden" />
85+
<DialogOverlay />
7786
<DialogContent
7887
ref="dialogContentRef"
7988
v-bind="forwarded"

packages/components/src/modal/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ function handleAnimationEnd() {
216216
</script>
217217

218218
<template>
219-
<Dialog :open="isOpen" @update:open="updateOpen">
219+
<Dialog :modal="false" :open="isOpen" @update:open="updateOpen">
220220
<DialogContent
221221
ref="dialogContentRef"
222222
:modal-id="modalId"

0 commit comments

Comments
 (0)