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.

[WEB-1902] fix: last draft issue properties (#5110)

Anmol Singh Bhatia1a2676829107
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<IssueFormProps> = observer((props) => {
.finally(() => setIAmFeelingLucky(false));
};
+ const condition =
+ (watch("name") && watch("name") !== "") || (watch("description_html") && watch("description_html") !== "<p></p>");
+
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<IssueFormProps> = 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<IssueFormProps> = observer((props) => {
<div className="h-7">
<DateDropdown
value={value}
- onChange={(date) => 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<IssueFormProps> = observer((props) => {
<div className="h-7">
<DateDropdown
value={value}
- onChange={(date) => onChange(date ? renderFormattedPayloadDate(date) : null)}
+ onChange={(date) => {
+ onChange(date ? renderFormattedPayloadDate(date) : null);
+ handleFormChange();
+ }}
buttonVariant="border-with-text"
minDate={minDate ?? undefined}
placeholder="Due date"