mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-22 17:49:48 +02:00
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 <github@multica.ai>
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user