From b5ed602e05fb937d70f3dc9704389cd4c83b269c Mon Sep 17 00:00:00 2001 From: guru_sainath Date: Fri, 22 Mar 2024 18:46:38 +0530 Subject: [PATCH] fix: disbaled the issue property check in the issue create/edit modal (#4038) --- .../issues/issue-modal/draft-issue-layout.tsx | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/web/components/issues/issue-modal/draft-issue-layout.tsx b/web/components/issues/issue-modal/draft-issue-layout.tsx index 240968faa..799a6bc4a 100644 --- a/web/components/issues/issue-modal/draft-issue-layout.tsx +++ b/web/components/issues/issue-modal/draft-issue-layout.tsx @@ -49,28 +49,33 @@ export const DraftIssueLayout: React.FC = observer((props) => { const { captureIssueEvent } = useEventTracker(); const handleClose = () => { - if (changesMade) { - Object.entries(changesMade).forEach(([key, value]) => { - const issueKey = key as keyof TIssue; - if (value === null || value === undefined || value === "") delete changesMade[issueKey]; - if (typeof value === "object" && isEmpty(value)) delete changesMade[issueKey]; - if (Array.isArray(value) && value.length === 0) delete changesMade[issueKey]; - if (issueKey === "project_id") delete changesMade.project_id; - if (issueKey === "priority" && value && value === "none") delete changesMade.priority; - if ( - issueKey === "description_html" && - changesMade.description_html && - isEmptyHtmlString(changesMade.description_html) - ) - delete changesMade.description_html; - }); - if (isEmpty(changesMade)) { - onClose(false); - setIssueDiscardModal(false); - } else setIssueDiscardModal(true); - } else { + if (data?.id) { onClose(false); setIssueDiscardModal(false); + } else { + if (changesMade) { + Object.entries(changesMade).forEach(([key, value]) => { + const issueKey = key as keyof TIssue; + if (value === null || value === undefined || value === "") delete changesMade[issueKey]; + if (typeof value === "object" && isEmpty(value)) delete changesMade[issueKey]; + if (Array.isArray(value) && value.length === 0) delete changesMade[issueKey]; + if (issueKey === "project_id") delete changesMade.project_id; + if (issueKey === "priority" && value && value === "none") delete changesMade.priority; + if ( + issueKey === "description_html" && + changesMade.description_html && + isEmptyHtmlString(changesMade.description_html) + ) + delete changesMade.description_html; + }); + if (isEmpty(changesMade)) { + onClose(false); + setIssueDiscardModal(false); + } else setIssueDiscardModal(true); + } else { + onClose(false); + setIssueDiscardModal(false); + } } };