fix(FormGroup): remove id when used with RadioGroup (#2152)

This commit is contained in:
Romain Hamel
2024-09-06 18:59:17 +02:00
committed by GitHub
parent 8d79eea19b
commit 7aec42ca15
2 changed files with 5 additions and 3 deletions

View File

@@ -104,7 +104,7 @@ export default defineComponent({
const { ui, attrs } = useUI('radioGroup', toRef(props, 'ui'), config, toRef(props, 'class'))
const { ui: uiRadio } = useUI('radio', toRef(props, 'uiRadio'), configRadio)
const { emitFormChange, color, name } = useFormGroup(props, config)
const { emitFormChange, color, name } = useFormGroup(props, config, false)
provide('radio-group', { color, name })
const onUpdate = (value: any) => {

View File

@@ -12,13 +12,15 @@ type InputProps = {
}
export const useFormGroup = (inputProps?: InputProps, config?: any) => {
export const useFormGroup = (inputProps?: InputProps, config?: any, bind: boolean = true) => {
const formBus = inject<UseEventBusReturn<FormEvent, string> | undefined>('form-events', undefined)
const formGroup = inject<InjectedFormGroupValue | undefined>('form-group', undefined)
const formInputs = inject<any>('form-inputs', undefined)
if (formGroup) {
if (inputProps?.id) {
if (!bind || inputProps.legend) {
formGroup.inputId.value = undefined
} else if (inputProps?.id) {
// Updates for="..." attribute on label if inputProps.id is provided
formGroup.inputId.value = inputProps?.id
}