From fc8ddc9785ccf4cf60990feb2cb9f0001c72c244 Mon Sep 17 00:00:00 2001 From: Jiayuan Date: Fri, 1 May 2026 09:22:39 +0200 Subject: [PATCH] fix(ui): guard Cmd+B sidebar shortcut against editable elements Skip the sidebar toggle when focus is inside INPUT, TEXTAREA, SELECT, or contentEditable elements so the shortcut does not steal Cmd+B (bold) from TipTap editors. Co-authored-by: multica-agent --- packages/ui/components/ui/sidebar.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/ui/components/ui/sidebar.tsx b/packages/ui/components/ui/sidebar.tsx index a981218194..a2c0afbbf4 100644 --- a/packages/ui/components/ui/sidebar.tsx +++ b/packages/ui/components/ui/sidebar.tsx @@ -112,6 +112,8 @@ function SidebarProvider({ }, [isMobile, setOpen, setOpenMobile]) // Toggle sidebar with keyboard shortcut (Cmd+B / Ctrl+B). + // Skip when focus is inside editable content so the shortcut doesn't + // steal Cmd+B (bold) from TipTap / contentEditable / inputs. React.useEffect(() => { const handleKeyDown = (event: KeyboardEvent) => { if ( @@ -120,6 +122,13 @@ function SidebarProvider({ !event.shiftKey && !event.altKey ) { + const tag = (event.target as HTMLElement)?.tagName + const isEditable = + tag === "INPUT" || + tag === "TEXTAREA" || + tag === "SELECT" || + (event.target as HTMLElement)?.isContentEditable + if (isEditable) return event.preventDefault() toggleSidebar() }