From b53b0bc3f09eaff0f1ddc2c28cbe6cdf69a57c00 Mon Sep 17 00:00:00 2001 From: Dakshesh Jain <65905942+dakshesh14@users.noreply.github.com> Date: Thu, 23 Feb 2023 19:56:18 +0530 Subject: [PATCH] fix: create issue modal close on escape click (#333) --- apps/app/components/issues/modal.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/apps/app/components/issues/modal.tsx b/apps/app/components/issues/modal.tsx index c69faa0eb..28689e6cd 100644 --- a/apps/app/components/issues/modal.tsx +++ b/apps/app/components/issues/modal.tsx @@ -75,6 +75,19 @@ export const CreateUpdateIssueModal: React.FC = ({ setActiveProject(projects?.find((p) => p.id === projectId)?.id ?? projects?.[0].id ?? null); }, [projectId, projects]); + useEffect(() => { + const handleKeyDown = (e: KeyboardEvent) => { + if (e.key === "Escape") { + handleClose(); + } + }; + + window.addEventListener("keydown", handleKeyDown); + return () => { + window.removeEventListener("keydown", handleKeyDown); + }; + }, []); + const addIssueToCycle = async (issueId: string, cycleId: string) => { if (!workspaceSlug || !projectId) return;