Skip to content

armgit / plane

Public Imported from GitHub
0

πŸ”₯πŸ”₯πŸ”₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.

chore: updated input validation on create and update estimate point form (#4900)

guru_sainath69d67fc02a32
diff --git a/web/core/components/estimates/points/create.tsx b/web/core/components/estimates/points/create.tsx
index 9cd7d1e7c9..274b19d901 100644
--- a/web/core/components/estimates/points/create.tsx
+++ b/web/core/components/estimates/points/create.tsx
@@ -149,6 +149,15 @@ export const EstimatePointCreate: FC<TEstimatePointCreate> = observer((props) =>
} else handleEstimatePointError && handleEstimatePointError(estimateInputValue, "Estimate value cannot be empty.");
};
+ // derived values
+ const inputFieldType =
+ estimateType && [(EEstimateSystem.TIME, EEstimateSystem.POINTS)].includes(estimateType) ? "number" : "text";
+ const inputProps = {
+ type: inputFieldType,
+ pattern: inputFieldType === "number" ? "[0-9]*" : undefined,
+ maxlength: inputFieldType === "number" ? undefined : 24,
+ };
+
return (
<form onSubmit={handleCreate} className="relative flex items-center gap-2 text-base pr-2.5">
<div
@@ -158,12 +167,12 @@ export const EstimatePointCreate: FC<TEstimatePointCreate> = observer((props) =>
)}
>
<input
- type="text"
value={estimateInputValue}
onChange={(e) => handleEstimateInputValue(e.target.value)}
className="border-none focus:ring-0 focus:border-0 focus:outline-none p-2.5 w-full bg-transparent"
placeholder="Enter estimate point"
autoFocus
+ {...inputProps}
/>
{estimatePointError?.message && (
<Tooltip
diff --git a/web/core/components/estimates/points/update.tsx b/web/core/components/estimates/points/update.tsx
index b557a6658e..c0f1df6a45 100644
--- a/web/core/components/estimates/points/update.tsx
+++ b/web/core/components/estimates/points/update.tsx
@@ -157,6 +157,15 @@ export const EstimatePointUpdate: FC<TEstimatePointUpdate> = observer((props) =>
handleEstimatePointError && handleEstimatePointError(estimateInputValue || "", "Estimate value cannot be empty.");
};
+ // derived values
+ const inputFieldType =
+ estimateType && [(EEstimateSystem.TIME, EEstimateSystem.POINTS)].includes(estimateType) ? "number" : "text";
+ const inputProps = {
+ type: inputFieldType,
+ pattern: inputFieldType === "number" ? "[0-9]*" : undefined,
+ maxlength: inputFieldType === "number" ? undefined : 24,
+ };
+
return (
<form onSubmit={handleUpdate} className="relative flex items-center gap-2 text-base pr-2.5">
<div
@@ -166,12 +175,12 @@ export const EstimatePointUpdate: FC<TEstimatePointUpdate> = observer((props) =>
)}
>
<input
- type="text"
value={estimateInputValue}
onChange={(e) => handleEstimateInputValue(e.target.value)}
className="border-none focus:ring-0 focus:border-0 focus:outline-none p-2.5 w-full bg-transparent"
placeholder="Enter estimate point"
autoFocus
+ {...inputProps}
/>
{estimatePointError?.message && (
<>