Skip to content

Commit 41087d4

Browse files
committed
fix(Drawer): improve title & description accessibility
Related to #4199 Follow-up e419dcb
1 parent 6aab62e commit 41087d4

File tree

3 files changed

+59
-3
lines changed

3 files changed

+59
-3
lines changed

src/runtime/components/Drawer.vue

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export interface DrawerSlots {
5656

5757
<script setup lang="ts">
5858
import { computed, toRef } from 'vue'
59-
import { useForwardPropsEmits } from 'reka-ui'
59+
import { VisuallyHidden, useForwardPropsEmits } from 'reka-ui'
6060
import { DrawerRoot, DrawerTrigger, DrawerPortal, DrawerOverlay, DrawerContent, DrawerTitle, DrawerDescription, DrawerHandle } from 'vaul-vue'
6161
import { reactivePick } from '@vueuse/core'
6262
import { useAppConfig } from '#imports'
@@ -101,6 +101,20 @@ const ui = computed(() => tv({ extend: tv(theme), ...(appConfig.ui?.drawer || {}
101101
<DrawerContent :class="ui.content({ class: [!slots.default && props.class, props.ui?.content] })" v-bind="contentProps" v-on="contentEvents">
102102
<DrawerHandle v-if="handle" :class="ui.handle({ class: props.ui?.handle })" />
103103

104+
<VisuallyHidden v-if="!!slots.content && ((title || !!slots.title) || (description || !!slots.description))">
105+
<DrawerTitle v-if="title || !!slots.title">
106+
<slot name="title">
107+
{{ title }}
108+
</slot>
109+
</DrawerTitle>
110+
111+
<DrawerDescription v-if="description || !!slots.description">
112+
<slot name="description">
113+
{{ description }}
114+
</slot>
115+
</DrawerDescription>
116+
</VisuallyHidden>
117+
104118
<slot name="content">
105119
<div :class="ui.container({ class: props.ui?.container })">
106120
<div v-if="!!slots.header || (title || !!slots.title) || (description || !!slots.description)" :class="ui.header({ class: props.ui?.header })">

0 commit comments

Comments
 (0)