From f8942f6eab5d1dd740618acc1970266d6e94709f Mon Sep 17 00:00:00 2001 From: Koustav Das <78158736+Koustavd18@users.noreply.github.com> Date: Thu, 23 Jan 2025 17:44:26 +0530 Subject: [PATCH] Esc key press to close querier modal (#434) --- src/pages/Stream/components/Querier/index.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/pages/Stream/components/Querier/index.tsx b/src/pages/Stream/components/Querier/index.tsx index f0b39565..5a4d001a 100644 --- a/src/pages/Stream/components/Querier/index.tsx +++ b/src/pages/Stream/components/Querier/index.tsx @@ -107,6 +107,20 @@ const QuerierModal = (props: { } }, [showQueryBuilder]); + useEffect(() => { + const handleKeyPress = (event: { key: string }) => { + if (event.key === 'Escape') { + onClose(); + } + }; + + window.addEventListener('keydown', handleKeyPress); + + return () => { + window.removeEventListener('keydown', handleKeyPress); + }; + }, []); + return (