Skip to content

Commit cd8eff5

Browse files
committed
修复 FaDrawer and FaModal 组件在头部不显示时的警告
1 parent e4ef644 commit cd8eff5

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/ui/components/FaDrawer/index.vue

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup lang="ts">
22
import type { DrawerEmits, DrawerProps } from '.'
3+
import { VisuallyHidden } from 'reka-ui'
34
import { cn } from '@/utils'
45
import {
56
Sheet,
@@ -42,6 +43,12 @@ const props = withDefaults(
4243
4344
const emits = defineEmits<DrawerEmits>()
4445
46+
const slots = defineSlots<{
47+
header?: () => VNode
48+
default?: () => VNode
49+
footer?: () => VNode
50+
}>()
51+
4552
const drawerId = shallowRef(props.id ?? useId())
4653
const isOpen = ref(props.modelValue)
4754
@@ -185,6 +192,10 @@ function handleAnimationEnd() {
185192
'border-b': props.bordered,
186193
})"
187194
>
195+
<VisuallyHidden v-if="!!slots.header">
196+
<SheetTitle />
197+
<SheetDescription />
198+
</VisuallyHidden>
188199
<slot name="header">
189200
<SheetTitle :class="{ 'text-center': props.centered }">
190201
{{ title }}
@@ -194,8 +205,12 @@ function handleAnimationEnd() {
194205
</SheetDescription>
195206
</slot>
196207
</SheetHeader>
208+
<VisuallyHidden v-else>
209+
<SheetTitle />
210+
<SheetDescription />
211+
</VisuallyHidden>
197212
<div class="m-0 flex-1 of-y-hidden">
198-
<FaScrollArea class="h-full">
213+
<FaScrollArea v-if="!!slots.default" class="h-full">
199214
<div class="p-4">
200215
<slot />
201216
</div>

src/ui/components/FaModal/index.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,10 @@ function handleAnimationEnd() {
269269
</DialogDescription>
270270
</slot>
271271
</DialogHeader>
272+
<VisuallyHidden v-else>
273+
<DialogTitle />
274+
<DialogDescription />
275+
</VisuallyHidden>
272276
<FaScrollArea v-if="!!slots.default" ref="dialogAreaRef" class="flex-1">
273277
<div :class="cn('min-h-40 p-4', props.contentClass)">
274278
<slot />

0 commit comments

Comments
 (0)