Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/web/core/components/estimates/inputs/number-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function EstimateNumberInput(props: TEstimateNumberInputProps) {
className="border-none focus:ring-0 focus:border-0 focus:outline-none px-2 py-2 w-full bg-transparent text-13"
placeholder={t("project_settings.estimates.create.enter_estimate_point")}
autoFocus
type="number"
step="any"
/>
);
}
3 changes: 1 addition & 2 deletions apps/web/core/components/estimates/inputs/root.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { FC } from "react";
// plane imports
import type { TEstimateSystemKeys } from "@plane/types";
import { EEstimateSystem } from "@plane/types";
Expand All @@ -21,7 +20,7 @@ export function EstimateInputRoot(props: TEstimateInputRootProps) {
case EEstimateSystem.POINTS:
return (
<EstimateNumberInput
value={value ? parseInt(value) : undefined}
value={value ? parseFloat(value) : undefined}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Add validation to handle invalid numeric input.

parseFloat(value) returns NaN when the input string is not a valid number. This NaN value would be passed to EstimateNumberInput, potentially causing unexpected behavior or display issues.

Consider adding validation:

🔎 Proposed fix to validate parsed value
-        value={value ? parseFloat(value) : undefined}
+        value={value ? (isNaN(parseFloat(value)) ? undefined : parseFloat(value)) : undefined}

Or extract to a variable for clarity:

+      const parsedValue = value ? parseFloat(value) : undefined;
       return (
         <EstimateNumberInput
-          value={value ? parseFloat(value) : undefined}
+          value={parsedValue !== undefined && !isNaN(parsedValue) ? parsedValue : undefined}
           handleEstimateInputValue={handleEstimateInputValue}
         />
       );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
value={value ? parseFloat(value) : undefined}
value={value ? (isNaN(parseFloat(value)) ? undefined : parseFloat(value)) : undefined}
🤖 Prompt for AI Agents
In @apps/web/core/components/estimates/inputs/root.tsx at line 23, The value
prop currently uses parseFloat(value) which yields NaN for invalid numeric
strings and can break EstimateNumberInput; validate the parsed number before
passing it in by parsing into a variable (e.g., parsed = parseFloat(value)) and
only pass parsed if Number.isFinite(parsed) (otherwise pass undefined) so
EstimateNumberInput never receives NaN; update the value prop usage in the
component that renders EstimateNumberInput accordingly.

handleEstimateInputValue={handleEstimateInputValue}
/>
);
Expand Down
Loading