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: input character limit error message improvement (#4271)

Anmol Singh Bhatia87737dbfbe99
diff --git a/packages/ui/src/form-fields/input.tsx b/packages/ui/src/form-fields/input.tsx
index f73467621b..04182ef132 100644
--- a/packages/ui/src/form-fields/input.tsx
+++ b/packages/ui/src/form-fields/input.tsx
@@ -27,9 +27,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>((props, ref) => {
: mode === "true-transparent"
? "rounded border-none bg-transparent ring-0"
: ""
- } ${hasError ? "border-red-500" : ""} ${hasError && mode === "primary" ? "bg-red-500/20" : ""} ${
- inputSize === "sm" ? "px-3 py-2" : inputSize === "md" ? "p-3" : ""
- }`,
+ } ${hasError ? "border-red-500" : ""} ${inputSize === "sm" ? "px-3 py-2" : inputSize === "md" ? "p-3" : ""}`,
className
)}
{...rest}
diff --git a/web/components/cycles/form.tsx b/web/components/cycles/form.tsx
index f8092f8d06..b8b34fe3b1 100644
--- a/web/components/cycles/form.tsx
+++ b/web/components/cycles/form.tsx
@@ -77,7 +77,7 @@ export const CycleForm: React.FC<Props> = (props) => {
</div>
<div className="space-y-3">
<div className="mt-2 space-y-3">
- <div>
+ <div className="flex flex-col gap-1">
<Controller
name="name"
control={control}
@@ -85,7 +85,7 @@ export const CycleForm: React.FC<Props> = (props) => {
required: "Name is required",
maxLength: {
value: 255,
- message: "Name should be less than 255 characters",
+ message: "Title should be less than 255 characters",
},
}}
render={({ field: { value, onChange } }) => (
@@ -103,6 +103,7 @@ export const CycleForm: React.FC<Props> = (props) => {
/>
)}
/>
+ <span className="text-xs text-red-500">{errors?.name?.message}</span>
</div>
<div>
<Controller
diff --git a/web/components/inbox/modals/create-edit-modal/create-root.tsx b/web/components/inbox/modals/create-edit-modal/create-root.tsx
index d2a0d1a2f2..de8e0d3ce2 100644
--- a/web/components/inbox/modals/create-edit-modal/create-root.tsx
+++ b/web/components/inbox/modals/create-edit-modal/create-root.tsx
@@ -116,10 +116,16 @@ export const InboxIssueCreateRoot: FC<TInboxIssueCreateRoot> = observer((props)
setFormSubmitting(false);
};
+ const isTitleLengthMoreThan255Character = formData?.name ? formData.name.length > 255 : false;
+
if (!workspaceSlug || !projectId || !workspaceId) return <></>;
return (
<form className="relative space-y-4" onSubmit={handleFormSubmit}>
- <InboxIssueTitle data={formData} handleData={handleFormData} />
+ <InboxIssueTitle
+ data={formData}
+ handleData={handleFormData}
+ isTitleLengthMoreThan255Character={isTitleLengthMoreThan255Character}
+ />
<InboxIssueDescription
workspaceSlug={workspaceSlug}
projectId={projectId}
@@ -138,7 +144,13 @@ export const InboxIssueCreateRoot: FC<TInboxIssueCreateRoot> = observer((props)
<Button variant="neutral-primary" size="sm" type="button" onClick={handleModalClose}>
Discard
</Button>
- <Button variant="primary" size="sm" type="submit" loading={formSubmitting}>
+ <Button
+ variant="primary"
+ size="sm"
+ type="submit"
+ loading={formSubmitting}
+ disabled={isTitleLengthMoreThan255Character}
+ >
{formSubmitting ? "Adding Issue..." : "Add Issue"}
</Button>
</div>
diff --git a/web/components/inbox/modals/create-edit-modal/edit-root.tsx b/web/components/inbox/modals/create-edit-modal/edit-root.tsx
index 7747245060..6ffb6efeed 100644
--- a/web/components/inbox/modals/create-edit-modal/edit-root.tsx
+++ b/web/components/inbox/modals/create-edit-modal/edit-root.tsx
@@ -121,10 +121,16 @@ export const InboxIssueEditRoot: FC<TInboxIssueEditRoot> = observer((props) => {
setFormSubmitting(false);
};
+ const isTitleLengthMoreThan255Character = formData?.name ? formData.name.length > 255 : false;
+
if (!workspaceSlug || !projectId || !workspaceId || !formData) return <></>;
return (
<div className="relative space-y-4">
- <InboxIssueTitle data={formData} handleData={handleFormData} />
+ <InboxIssueTitle
+ data={formData}
+ handleData={handleFormData}
+ isTitleLengthMoreThan255Character={isTitleLengthMoreThan255Character}
+ />
<InboxIssueDescription
workspaceSlug={workspaceSlug}
projectId={projectId}
@@ -138,7 +144,14 @@ export const InboxIssueEditRoot: FC<TInboxIssueEditRoot> = observer((props) => {
<Button variant="neutral-primary" size="sm" type="button" onClick={handleModalClose}>
Cancel
</Button>
- <Button variant="primary" size="sm" type="button" loading={formSubmitting} onClick={handleFormSubmit}>
+ <Button
+ variant="primary"
+ size="sm"
+ type="button"
+ loading={formSubmitting}
+ disabled={isTitleLengthMoreThan255Character}
+ onClick={handleFormSubmit}
+ >
{formSubmitting ? "Adding..." : "Add to project"}
</Button>
</div>
diff --git a/web/components/inbox/modals/create-edit-modal/issue-title.tsx b/web/components/inbox/modals/create-edit-modal/issue-title.tsx
index 27361b1f4e..31a44bf767 100644
--- a/web/components/inbox/modals/create-edit-modal/issue-title.tsx
+++ b/web/components/inbox/modals/create-edit-modal/issue-title.tsx
@@ -6,10 +6,11 @@ import { Input } from "@plane/ui";
type TInboxIssueTitle = {
data: Partial<TIssue>;
handleData: (issueKey: keyof Partial<TIssue>, issueValue: Partial<TIssue>[keyof Partial<TIssue>]) => void;
+ isTitleLengthMoreThan255Character?: boolean;
};
export const InboxIssueTitle: FC<TInboxIssueTitle> = observer((props) => {
- const { data, handleData } = props;
+ const { data, handleData, isTitleLengthMoreThan255Character } = props;
return (
<div className="relative flex flex-wrap gap-2 items-center">
@@ -21,9 +22,11 @@ export const InboxIssueTitle: FC<TInboxIssueTitle> = observer((props) => {
onChange={(e) => handleData("name", e.target.value)}
placeholder="Title"
className="w-full resize-none text-xl"
- maxLength={255}
required
/>
+ {isTitleLengthMoreThan255Character && (
+ <span className="text-xs text-red-500">Title should be less than 255 characters</span>
+ )}
</div>
);
});
diff --git a/web/components/issues/issue-modal/form.tsx b/web/components/issues/issue-modal/form.tsx
index 50f60bac51..2e426c9e86 100644
--- a/web/components/issues/issue-modal/form.tsx
+++ b/web/components/issues/issue-modal/form.tsx
@@ -391,6 +391,8 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => {
/>
)}
/>
+ <span className="text-xs text-red-500">{errors?.name?.message}</span>
+
<div className="relative">
{data?.description_html === undefined ? (
<Loader className="min-h-[7rem] space-y-2 overflow-hidden rounded-md border border-custom-border-200 p-2 py-2">
diff --git a/web/components/modules/form.tsx b/web/components/modules/form.tsx
index 30749218d1..d49a070b1d 100644
--- a/web/components/modules/form.tsx
+++ b/web/components/modules/form.tsx
@@ -90,7 +90,7 @@ export const ModuleForm: React.FC<Props> = (props) => {
</div>
<div className="space-y-3">
- <div>
+ <div className="flex flex-col gap-1">
<Controller
control={control}
name="name"
@@ -109,13 +109,14 @@ export const ModuleForm: React.FC<Props> = (props) => {
value={value}
onChange={onChange}
ref={ref}
- hasError={Boolean(errors.name)}
+ hasError={Boolean(errors?.name)}
placeholder="Module Title"
className="w-full resize-none placeholder:text-sm placeholder:font-medium focus:border-blue-400"
tabIndex={1}
/>
)}
/>
+ <span className="text-xs text-red-500">{errors?.name?.message}</span>
</div>
<div>
<Controller
diff --git a/web/components/project/form.tsx b/web/components/project/form.tsx
index f2a87a173d..f617910f22 100644
--- a/web/components/project/form.tsx
+++ b/web/components/project/form.tsx
@@ -216,6 +216,10 @@ export const ProjectDetailsForm: FC<IProjectDetailsForm> = (props) => {
name="name"
rules={{
required: "Name is required",
+ maxLength: {
+ value: 255,
+ message: "Project name should be less than 255 characters",
+ },
}}
render={({ field: { value, onChange, ref } }) => (
<Input
@@ -232,9 +236,7 @@ export const ProjectDetailsForm: FC<IProjectDetailsForm> = (props) => {
/>
)}
/>
- <span className="text-xs text-red-500">
- <>{errors?.name?.message}</>
- </span>
+ <span className="text-xs text-red-500">{errors?.name?.message}</span>
</div>
<div className="flex flex-col gap-1">
<h4 className="text-sm">Description</h4>
diff --git a/web/components/views/form.tsx b/web/components/views/form.tsx
index a8fa6b87cb..cc1994eca0 100644
--- a/web/components/views/form.tsx
+++ b/web/components/views/form.tsx
@@ -112,7 +112,7 @@ export const ProjectViewForm: React.FC<Props> = observer((props) => {
<div className="space-y-5">
<h3 className="text-lg font-medium leading-6 text-custom-text-100">{data ? "Update" : "Create"} View</h3>
<div className="space-y-3">
- <div>
+ <div className="flex flex-col gap-1">
<Controller
control={control}
name="name"
@@ -137,6 +137,7 @@ export const ProjectViewForm: React.FC<Props> = observer((props) => {
/>
)}
/>
+ <span className="text-xs text-red-500">{errors?.name?.message}</span>
</div>
<div>
<Controller
@@ -215,8 +216,8 @@ export const ProjectViewForm: React.FC<Props> = observer((props) => {
? "Updating View..."
: "Update View"
: isSubmitting
- ? "Creating View..."
- : "Create View"}
+ ? "Creating View..."
+ : "Create View"}
</Button>
</div>
</form>
diff --git a/web/components/workspace/create-workspace-form.tsx b/web/components/workspace/create-workspace-form.tsx
index d8a443d4db..789e2ee851 100644
--- a/web/components/workspace/create-workspace-form.tsx
+++ b/web/components/workspace/create-workspace-form.tsx
@@ -125,35 +125,38 @@ export const CreateWorkspaceForm: FC<Props> = observer((props) => {
Workspace Name
<span className="ml-0.5 text-red-500">*</span>
</label>
- <Controller
- control={control}
- name="name"
- rules={{
- required: "Workspace name is required",
- validate: (value) =>
- /^[\w\s-]*$/.test(value) || `Name can only contain (" "), ( - ), ( _ ) & alphanumeric characters.`,
- maxLength: {
- value: 80,
- message: "Workspace name should not exceed 80 characters",
- },
- }}
- render={({ field: { value, ref, onChange } }) => (
- <Input
- id="workspaceName"
- type="text"
- value={value}
- onChange={(e) => {
- onChange(e.target.value);
- setValue("name", e.target.value);
- setValue("slug", e.target.value.toLocaleLowerCase().trim().replace(/ /g, "-"));
- }}
- ref={ref}
- hasError={Boolean(errors.name)}
- placeholder="Enter workspace name..."
- className="w-full"
- />
- )}
- />
+ <div className="flex flex-col gap-1">
+ <Controller
+ control={control}
+ name="name"
+ rules={{
+ required: "Workspace name is required",
+ validate: (value) =>
+ /^[\w\s-]*$/.test(value) || `Name can only contain (" "), ( - ), ( _ ) & alphanumeric characters.`,
+ maxLength: {
+ value: 80,
+ message: "Workspace name should not exceed 80 characters",
+ },
+ }}
+ render={({ field: { value, ref, onChange } }) => (
+ <Input
+ id="workspaceName"
+ type="text"
+ value={value}
+ onChange={(e) => {
+ onChange(e.target.value);
+ setValue("name", e.target.value);
+ setValue("slug", e.target.value.toLocaleLowerCase().trim().replace(/ /g, "-"));
+ }}
+ ref={ref}
+ hasError={Boolean(errors.name)}
+ placeholder="Enter workspace name..."
+ className="w-full"
+ />
+ )}
+ />
+ <span className="text-xs text-red-500">{errors?.name?.message}</span>
+ </div>
</div>
<div className="space-y-1 text-sm">
<label htmlFor="workspaceUrl">