Skip to content

Commit f3c2ac2

Browse files
61021claude
andauthored
fix(Slider): bind form aria attributes on thumbs instead of root (#6768)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent f065438 commit f3c2ac2

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

src/runtime/components/Slider.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ function onChange(value: any) {
118118

119119
<template>
120120
<SliderRoot
121-
v-bind="{ ...rootProps, ...ariaAttrs }"
121+
v-bind="rootProps"
122122
:id="id"
123123
v-model="sliderValue"
124124
:name="name"
@@ -140,9 +140,9 @@ function onChange(value: any) {
140140
disable-closing-trigger
141141
v-bind="(typeof props.tooltip === 'object' ? props.tooltip : {})"
142142
>
143-
<SliderThumb data-slot="thumb" :class="ui.thumb({ class: props.ui?.thumb })" :aria-label="thumbs === 1 ? 'Thumb' : `Thumb ${thumb} of ${thumbs}`" />
143+
<SliderThumb data-slot="thumb" :class="ui.thumb({ class: props.ui?.thumb })" :aria-label="thumbs === 1 ? 'Thumb' : `Thumb ${thumb} of ${thumbs}`" v-bind="ariaAttrs" />
144144
</UTooltip>
145-
<SliderThumb v-else data-slot="thumb" :class="ui.thumb({ class: props.ui?.thumb })" :aria-label="thumbs === 1 ? 'Thumb' : `Thumb ${thumb} of ${thumbs}`" />
145+
<SliderThumb v-else data-slot="thumb" :class="ui.thumb({ class: props.ui?.thumb })" :aria-label="thumbs === 1 ? 'Thumb' : `Thumb ${thumb} of ${thumbs}`" v-bind="ariaAttrs" />
146146
</template>
147147
</SliderRoot>
148148
</template>

test/components/FormField.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,20 @@ describe('FormField', () => {
133133
})
134134
}
135135

136+
if (name === 'Slider') {
137+
test('binds aria attributes on the thumb', async () => {
138+
const wrapper = await renderFormField({
139+
props: { error: 'Error' },
140+
inputComponent
141+
})
142+
143+
const invalid = wrapper.findAll('[aria-invalid="true"]')
144+
expect(invalid).toHaveLength(1)
145+
expect(invalid[0]!.attributes('role')).toBe('slider')
146+
expect(invalid[0]!.attributes('aria-describedby')).toBe('v-0-0-error')
147+
})
148+
}
149+
136150
test('binds hints with aria-describedby', async () => {
137151
const wrapper = await renderFormField({
138152
props: { hint: 'somehint' },

0 commit comments

Comments
 (0)