From 98859e7b1cad208485fb0b133d4c82c5c6355984 Mon Sep 17 00:00:00 2001 From: shadcn Date: Tue, 2 Jan 2024 11:48:27 +0400 Subject: [PATCH] feat(www): update keyboard handling for command menu (#2264) --- apps/www/components/command-menu.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/www/components/command-menu.tsx b/apps/www/components/command-menu.tsx index 96538809c63..0e5551cbeb6 100644 --- a/apps/www/components/command-menu.tsx +++ b/apps/www/components/command-menu.tsx @@ -32,7 +32,16 @@ export function CommandMenu({ ...props }: DialogProps) { React.useEffect(() => { const down = (e: KeyboardEvent) => { - if (e.key === "k" && (e.metaKey || e.ctrlKey)) { + if ((e.key === "k" && (e.metaKey || e.ctrlKey)) || e.key === "/") { + if ( + (e.target instanceof HTMLElement && e.target.isContentEditable) || + e.target instanceof HTMLInputElement || + e.target instanceof HTMLTextAreaElement || + e.target instanceof HTMLSelectElement + ) { + return + } + e.preventDefault() setOpen((open) => !open) }