From 266f14d5506e32eb53940c77f69bd62930248459 Mon Sep 17 00:00:00 2001 From: Prateek Shourya Date: Fri, 5 Jan 2024 14:38:09 +0530 Subject: [PATCH] fix: project identifier cursor behaviour in create project modal. (#3320) --- .../project/create-project-modal.tsx | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/web/components/project/create-project-modal.tsx b/web/components/project/create-project-modal.tsx index 2b657c810..61e5086bb 100644 --- a/web/components/project/create-project-modal.tsx +++ b/web/components/project/create-project-modal.tsx @@ -126,6 +126,8 @@ export const CreateProjectModal: FC = observer((props) => { else payload.emoji = formData.emoji_and_icon; payload.project_lead = formData.project_lead_member; + // Upper case identifier + payload.identifier = payload.identifier.toUpperCase(); return createProject(workspaceSlug.toString(), payload) .then((res) => { @@ -176,14 +178,7 @@ export const CreateProjectModal: FC = observer((props) => { return; } if (e.target.value === "") setValue("identifier", ""); - else - setValue( - "identifier", - e.target.value - .replace(/[^ÇŞĞIİÖÜA-Za-z0-9]/g, "") - .toUpperCase() - .substring(0, 5) - ); + else setValue("identifier", e.target.value.replace(/[^ÇŞĞIİÖÜA-Za-z0-9]/g, "").substring(0, 5)); onChange(e); }; @@ -191,7 +186,7 @@ export const CreateProjectModal: FC = observer((props) => { const { value } = e.target; const alphanumericValue = value.replace(/[^ÇŞĞIİÖÜA-Za-z0-9]/g, ""); setIsChangeInIdentifierRequired(false); - onChange(alphanumericValue.toUpperCase()); + onChange(alphanumericValue); }; return ( @@ -301,7 +296,8 @@ export const CreateProjectModal: FC = observer((props) => { required: "Identifier is required", // allow only alphanumeric & non-latin characters validate: (value) => - /^[ÇŞĞIİÖÜA-Z0-9]+$/.test(value.toUpperCase()) || "Identifier must be in uppercase.", + /^[ÇŞĞIİÖÜA-Z0-9]+$/.test(value.toUpperCase()) || + "Only Alphanumeric & Non-latin characters are allowed.", minLength: { value: 1, message: "Identifier must at least be of 1 character", @@ -321,7 +317,7 @@ export const CreateProjectModal: FC = observer((props) => { onChange={handleIdentifierChange(onChange)} hasError={Boolean(errors.identifier)} placeholder="Identifier" - className="w-full text-xs focus:border-blue-400" + className="w-full text-xs focus:border-blue-400 uppercase" /> )} />