From 1a26768291077b2bc33124f4d8ee89c5bc754450 Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia <121005188+anmolsinghbhatia@users.noreply.github.com> Date: Fri, 12 Jul 2024 19:49:23 +0530 Subject: [PATCH] [WEB-1902] fix: last draft issue properties (#5110) * fix: handleFormChange added to start and due date properties * fix: useEffect added to update localStorage when isDirty changes --- .../components/issues/issue-modal/form.tsx | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/web/core/components/issues/issue-modal/form.tsx b/web/core/components/issues/issue-modal/form.tsx index edd99f0337..b041cf3dd3 100644 --- a/web/core/components/issues/issue-modal/form.tsx +++ b/web/core/components/issues/issue-modal/form.tsx @@ -266,10 +266,13 @@ export const IssueFormRoot: FC = observer((props) => { .finally(() => setIAmFeelingLucky(false)); }; + const condition = + (watch("name") && watch("name") !== "") || (watch("description_html") && watch("description_html") !== "

"); + const handleFormChange = () => { if (!onChange) return; - if (isDirty && (watch("name") || watch("description_html"))) onChange(watch()); + if (isDirty && condition) onChange(watch()); else onChange(null); }; @@ -306,6 +309,14 @@ export const IssueFormRoot: FC = observer((props) => { } as ISearchIssueResponse); }, [watch, getIssueById, getProjectById, selectedParentIssue]); + // executing this useEffect when isDirty changes + useEffect(() => { + if (!onChange) return; + + if (isDirty && condition) onChange(watch()); + else onChange(null); + }, [isDirty]); + return ( <> {projectId && ( @@ -591,7 +602,10 @@ export const IssueFormRoot: FC = observer((props) => {
onChange(date ? renderFormattedPayloadDate(date) : null)} + onChange={(date) => { + onChange(date ? renderFormattedPayloadDate(date) : null); + handleFormChange(); + }} buttonVariant="border-with-text" maxDate={maxDate ?? undefined} placeholder="Start date" @@ -607,7 +621,10 @@ export const IssueFormRoot: FC = observer((props) => {
onChange(date ? renderFormattedPayloadDate(date) : null)} + onChange={(date) => { + onChange(date ? renderFormattedPayloadDate(date) : null); + handleFormChange(); + }} buttonVariant="border-with-text" minDate={minDate ?? undefined} placeholder="Due date"