Skip to content

Commit 7aec42c

Browse files
authored
fix(FormGroup): remove id when used with RadioGroup (#2152)
1 parent 8d79eea commit 7aec42c

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

‎src/runtime/components/forms/RadioGroup.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export default defineComponent({
104104
const { ui, attrs } = useUI('radioGroup', toRef(props, 'ui'), config, toRef(props, 'class'))
105105
const { ui: uiRadio } = useUI('radio', toRef(props, 'uiRadio'), configRadio)
106106
107-
const { emitFormChange, color, name } = useFormGroup(props, config)
107+
const { emitFormChange, color, name } = useFormGroup(props, config, false)
108108
provide('radio-group', { color, name })
109109
110110
const onUpdate = (value: any) => {

‎src/runtime/composables/useFormGroup.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ type InputProps = {
1212
}
1313

1414

15-
export const useFormGroup = (inputProps?: InputProps, config?: any) => {
15+
export const useFormGroup = (inputProps?: InputProps, config?: any, bind: boolean = true) => {
1616
const formBus = inject<UseEventBusReturn<FormEvent, string> | undefined>('form-events', undefined)
1717
const formGroup = inject<InjectedFormGroupValue | undefined>('form-group', undefined)
1818
const formInputs = inject<any>('form-inputs', undefined)
1919

2020
if (formGroup) {
21-
if (inputProps?.id) {
21+
if (!bind || inputProps.legend) {
22+
formGroup.inputId.value = undefined
23+
} else if (inputProps?.id) {
2224
// Updates for="..." attribute on label if inputProps.id is provided
2325
formGroup.inputId.value = inputProps?.id
2426
}

0 commit comments

Comments
 (0)