From 4d9cd0c3182e8d5f0e31492e863111c01952993e Mon Sep 17 00:00:00 2001 From: "M. Palanikannan" <73993394+Palanikannan1437@users.noreply.github.com> Date: Thu, 30 May 2024 17:53:49 +0530 Subject: [PATCH] fix: negate check while trying to discard (#4653) --- web/components/inbox/modals/create-edit-modal/create-root.tsx | 2 +- web/components/issues/issue-modal/form.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/components/inbox/modals/create-edit-modal/create-root.tsx b/web/components/inbox/modals/create-edit-modal/create-root.tsx index 08743f63c1b..36f1b0abe58 100644 --- a/web/components/inbox/modals/create-edit-modal/create-root.tsx +++ b/web/components/inbox/modals/create-edit-modal/create-root.tsx @@ -81,7 +81,7 @@ export const InboxIssueCreateRoot: FC = observer((props) const handleFormSubmit = async (event: FormEvent) => { event.preventDefault(); - if (descriptionEditorRef.current?.isEditorReadyToDiscard()) { + if (!descriptionEditorRef.current?.isEditorReadyToDiscard()) { setToast({ type: TOAST_TYPE.ERROR, title: "Error!", diff --git a/web/components/issues/issue-modal/form.tsx b/web/components/issues/issue-modal/form.tsx index 1d91e687e9f..9313f8f77f1 100644 --- a/web/components/issues/issue-modal/form.tsx +++ b/web/components/issues/issue-modal/form.tsx @@ -122,7 +122,7 @@ export const IssueFormRoot: FC = observer((props) => { const { getProjectById } = useProject(); const { areEstimatesEnabledForProject } = useEstimate(); - function handleKeyDown(event: KeyboardEvent) { + const handleKeyDown = (event: KeyboardEvent) => { if (editorRef.current?.isEditorReadyToDiscard()) { onClose(); } else { @@ -133,7 +133,7 @@ export const IssueFormRoot: FC = observer((props) => { }); event.preventDefault(); // Prevent default action if editor is not ready to discard } - } + }; useKeypress("Escape", handleKeyDown);