From dcdabd4d086a2ffc9a02674e324f03dd98949f0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20Gran=C3=A1t?= Date: Mon, 17 Jun 2024 16:31:45 +0200 Subject: [PATCH] fix: figma close on escape (#46) * fix: figma close on escape * fix: figma close on escape --- src/ui/components/Dialog/Dialog.tsx | 6 +++++- src/ui/views/Index/Index.tsx | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ui/components/Dialog/Dialog.tsx b/src/ui/components/Dialog/Dialog.tsx index d2514fd..99f9c25 100644 --- a/src/ui/components/Dialog/Dialog.tsx +++ b/src/ui/components/Dialog/Dialog.tsx @@ -15,7 +15,11 @@ export const Dialog = ({ children, onClose }: Props) => { useWindowSize(DEFAULT_SIZE); useEffect(() => { - const handler = () => onClose(); + const handler = (e: KeyboardEvent) => { + if (e.code === "Escape") { + onClose(); + } + }; ref.current?.focus(); ref.current?.addEventListener("keydown", handler); return () => ref.current?.removeEventListener("keydown", handler); diff --git a/src/ui/views/Index/Index.tsx b/src/ui/views/Index/Index.tsx index db2ea3a..44bf7cf 100644 --- a/src/ui/views/Index/Index.tsx +++ b/src/ui/views/Index/Index.tsx @@ -108,7 +108,7 @@ export const Index = () => { return (
- {selectionLoadable.isFetching && } + {selectionLoadable.isFetching && }