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"