mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-23 00:15:05 +01:00
fix(FormGroup): hydration mismatch on inputId (#942)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { inject, ref, computed, onMounted } from 'vue'
|
||||
import { type UseEventBusReturn, useDebounceFn } from '@vueuse/core'
|
||||
import type { FormEvent, FormEventType, InjectedFormGroupValue } from '../types/form'
|
||||
import { uid } from '../utils/uid'
|
||||
|
||||
type InputProps = {
|
||||
id?: string | null
|
||||
@@ -18,7 +19,8 @@ export const useFormGroup = (inputProps?: InputProps, config?: any) => {
|
||||
const inputId = ref(inputProps?.id)
|
||||
|
||||
onMounted(() => {
|
||||
inputId.value = inputProps?.isFieldset ? null : inputProps?.id ?? formGroup?.inputId.value
|
||||
inputId.value = inputProps?.isFieldset ? null : inputProps?.id ?? uid()
|
||||
|
||||
if (formGroup) {
|
||||
// Updates for="..." attribute on label if inputProps.id is provided
|
||||
formGroup.inputId.value = inputId.value
|
||||
|
||||
Reference in New Issue
Block a user