From fc38a425878ea5fe686c7989fcd7fa1bce46fd05 Mon Sep 17 00:00:00 2001 From: AprilNEA Date: Tue, 1 Oct 2024 14:36:45 +0000 Subject: [PATCH] fix: convert final value --- apps/dokploy/components/ui/input.tsx | 39 +++++++++++++++------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/apps/dokploy/components/ui/input.tsx b/apps/dokploy/components/ui/input.tsx index d8b94c79..4a537cef 100644 --- a/apps/dokploy/components/ui/input.tsx +++ b/apps/dokploy/components/ui/input.tsx @@ -39,24 +39,27 @@ const NumberInput = React.forwardRef( className={cn("text-left", className)} ref={ref} {...props} - onChange={(e) => { - const value = e.target.value; - if (value === "") { - props.onChange?.(e); - } else { - const number = Number.parseInt(value, 10); - if (!Number.isNaN(number)) { - const syntheticEvent = { - ...e, - target: { - ...e.target, - value: number.toString(), - }, - }; - props.onChange?.(syntheticEvent as React.ChangeEvent); - } - } - }} + value={props.value === undefined ? undefined : String(props.value)} + onChange={(e) => { + const value = e.target.value; + if (value === "") { + props.onChange?.(e); + } else { + const number = Number.parseInt(value, 10); + if (!Number.isNaN(number)) { + const syntheticEvent = { + ...e, + target: { + ...e.target, + value: number, + }, + }; + props.onChange?.( + syntheticEvent as unknown as React.ChangeEvent + ); + } + } + }} /> ); }