From fd4266dde6c862452756d859dc35408df31612bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Ign=C3=A1cio=20Fontoura=20Solla?= Date: Fri, 20 Mar 2026 12:20:30 -0300 Subject: [PATCH] Improve FormInput readability --- src/components/FormInput.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/FormInput.tsx b/src/components/FormInput.tsx index 43d557be..60436014 100644 --- a/src/components/FormInput.tsx +++ b/src/components/FormInput.tsx @@ -28,13 +28,16 @@ export const FormInput = < onChange, ...props }: FormInpuProps) => { - const { register } = useFormContext() - const { onChange: onValueChange, ...registerResult } = register(name, options) + const { onChange: onValueChange, ...registerResult } = useFormContext().register( + name, + options, + ) const handleChange: ChangeEventHandler = (e) => { - const targetValue = e.target.value - const formattedValue = format?.(targetValue) ?? targetValue - e.target.value = formattedValue + if (format) { + e.target.value = format(e.target.value) + } + onValueChange(e) onChange?.(e) }