fix: convert final value

This commit is contained in:
AprilNEA
2024-10-01 14:36:45 +00:00
parent c1c5fc978b
commit fc38a42587

View File

@@ -39,6 +39,7 @@ const NumberInput = React.forwardRef<HTMLInputElement, InputProps>(
className={cn("text-left", className)} className={cn("text-left", className)}
ref={ref} ref={ref}
{...props} {...props}
value={props.value === undefined ? undefined : String(props.value)}
onChange={(e) => { onChange={(e) => {
const value = e.target.value; const value = e.target.value;
if (value === "") { if (value === "") {
@@ -50,10 +51,12 @@ const NumberInput = React.forwardRef<HTMLInputElement, InputProps>(
...e, ...e,
target: { target: {
...e.target, ...e.target,
value: number.toString(), value: number,
}, },
}; };
props.onChange?.(syntheticEvent as React.ChangeEvent<HTMLInputElement>); props.onChange?.(
syntheticEvent as unknown as React.ChangeEvent<HTMLInputElement>
);
} }
} }
}} }}