fix(FormField): resolve minor accessibility and rendering issues (#4515)

Co-authored-by: Romain Hamel <rom.hml@gmail.com>
This commit is contained in:
Thilo Hettmer
2025-07-16 21:55:57 +02:00
committed by GitHub
parent 8b42365bf4
commit c64c4cdea0
7 changed files with 80 additions and 55 deletions

View File

@@ -121,7 +121,7 @@ provide(formFieldInjectionKey, computed(() => ({
{{ error }}
</slot>
</div>
<div v-else-if="help || !!slots.help" :class="ui.help({ class: props.ui?.help })">
<div v-else-if="help || !!slots.help" :id="`${ariaId}-help`" :class="ui.help({ class: props.ui?.help })">
<slot name="help" :help="help">
{{ help }}
</slot>

View File

@@ -89,10 +89,15 @@ export function useFormField<T>(props?: Props<T>, opts?: { bind?: boolean, defer
.filter(type => formField?.value?.[type])
.map(type => `${formField?.value.ariaId}-${type}`) || []
return {
'aria-describedby': descriptiveAttrs.join(' '),
const attrs: Record<string, any> = {
'aria-invalid': !!formField?.value.error
}
if (descriptiveAttrs.length > 0) {
attrs['aria-describedby'] = descriptiveAttrs.join(' ')
}
return attrs
})
}
}