diff --git a/src/admin/components/forms/useField/index.tsx b/src/admin/components/forms/useField/index.tsx index 3fb4a76dc1..1cf55e811a 100644 --- a/src/admin/components/forms/useField/index.tsx +++ b/src/admin/components/forms/useField/index.tsx @@ -33,17 +33,17 @@ const useField = (options: Options): FieldType => { setModified, } = formContext || {}; - const [internalValue, setInternalValue] = useState(undefined); - const [internallyValid, setInternallyValid] = useState(undefined); - - // Debounce internal values to update form state only every 60ms - const debouncedValue = useDebounce(internalValue, 120); - // Get field by path const field = getField(path); const initialValue = field?.initialValue as T; + const [internalValue, setInternalValue] = useState(field?.value as T); + const [internallyValid, setInternallyValid] = useState(undefined); + + // Debounce internal values to update form state only every 60ms + const debouncedValue = useDebounce(internalValue, 120); + // Validation is defined by two ways - // 1. by field state // 2. maintained locally to reflect instant validation state changes @@ -128,7 +128,6 @@ const useField = (options: Options): FieldType => { ]); useEffect(() => { - setInternalValue(initialValue); setInternallyValid(undefined); }, [initialValue]);