diff --git a/apps/dokploy/components/ui/input.tsx b/apps/dokploy/components/ui/input.tsx index 18b713af..7339d21a 100644 --- a/apps/dokploy/components/ui/input.tsx +++ b/apps/dokploy/components/ui/input.tsx @@ -39,7 +39,7 @@ const NumberInput = React.forwardRef( className={cn("text-left", className)} ref={ref} {...props} - value={props.value === undefined ? undefined : String(props.value)} + value={props.value === undefined || props.value === "" ? "" : String(props.value)} onChange={(e) => { const value = e.target.value; if (value === "") { @@ -60,6 +60,21 @@ const NumberInput = React.forwardRef( } } }} + onBlur={(e) => { + // If input is empty, make 0 when focus is lost + if (e.target.value === "") { + const syntheticEvent = { + ...e, + target: { + ...e.target, + value: "0", + }, + }; + props.onChange?.( + syntheticEvent as unknown as React.ChangeEvent, + ); + } + }} /> ); },