Skip to content

Commit

Permalink
fix(FormGroup): remove id when used with RadioGroup (#2152)
Browse files Browse the repository at this point in the history
  • Loading branch information
romhml authored Sep 6, 2024
1 parent 8d79eea commit 7aec42c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/runtime/components/forms/RadioGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
6 changes: 4 additions & 2 deletions src/runtime/composables/useFormGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 7aec42c

Please sign in to comment.