Context
packages/loopover-ui-kit/src/components/sidebar.tsx's SidebarProvider registers a document-level keydown listener (lines 104-117) that toggles the sidebar on Cmd/Ctrl+B:
React.useEffect(() => {
const handleKeyDown = (event: KeyboardEvent) => {
if (
event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
(event.metaKey || event.ctrlKey)
) {
event.preventDefault();
toggleSidebar();
}
};
window.addEventListener("keydown", handleKeyDown);
return () => window.removeEventListener("keydown", handleKeyDown);
}, [toggleSidebar]);
This handler fires regardless of what element currently has focus — including a text <input>, <textarea>, or contenteditable element. Since Cmd/Ctrl+B is the browser/OS-native "Bold" shortcut inside any editable text field, this handler's unconditional event.preventDefault() hijacks that native behavior and toggles the sidebar instead, every time, anywhere on the page a SidebarProvider is mounted.
This exact class of bug already has a fix precedent live in this same repo, twice: apps/loopover-ui/src/components/site/keyboard-shortcuts.tsx (lines 80-84) and apps/loopover-ui/src/components/site/app-shell.tsx (lines 129-131) both guard their own global keydown handlers with an isTyping()-style check before acting:
const isTyping = (el: EventTarget | null) => {
if (!(el instanceof HTMLElement)) return false;
const tag = el.tagName;
return tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT" || el.isContentEditable;
};
sidebar.tsx's handler has no equivalent guard.
Requirements
- Add the same
isTyping(event.target)-style guard (checking tagName === "INPUT" | "TEXTAREA" | "SELECT" or isContentEditable) to SidebarProvider's handleKeyDown, and return early (without calling toggleSidebar() or preventDefault()) when the event target is a form field or contenteditable element — mirroring keyboard-shortcuts.tsx's isTyping helper exactly, not a differently-shaped check.
- Keep the existing
metaKey/ctrlKey + key === SIDEBAR_KEYBOARD_SHORTCUT condition unchanged for the non-typing case.
- Do not change
toggleSidebar's own behavior, the cookie-persistence logic, or any other part of SidebarProvider.
Deliverables
Test Coverage Requirements
packages/loopover-ui-kit is not in the root vitest.config.ts's coverage.include and is not Codecov-gated — still add the regression test above (this package's own suite must run and pass per its vitest.config.ts's stated acceptance bar).
Expected Outcome
Typing "b" while holding Cmd/Ctrl inside any text input, textarea, or contenteditable element on a page using SidebarProvider no longer toggles the sidebar or blocks the browser's native Bold shortcut — matching the guard already applied to the other two global keyboard-shortcut handlers in this repo.
Links & Resources
apps/loopover-ui/src/components/site/keyboard-shortcuts.tsx:80-84 (the isTyping helper to mirror)
apps/loopover-ui/src/components/site/app-shell.tsx:129-131 (a second, independent instance of the same guard)
packages/loopover-ui-kit/src/components/sidebar.tsx:104-117 (the ungated handler)
Context
packages/loopover-ui-kit/src/components/sidebar.tsx'sSidebarProviderregisters a document-levelkeydownlistener (lines 104-117) that toggles the sidebar onCmd/Ctrl+B:This handler fires regardless of what element currently has focus — including a text
<input>,<textarea>, orcontenteditableelement. SinceCmd/Ctrl+Bis the browser/OS-native "Bold" shortcut inside any editable text field, this handler's unconditionalevent.preventDefault()hijacks that native behavior and toggles the sidebar instead, every time, anywhere on the page aSidebarProvideris mounted.This exact class of bug already has a fix precedent live in this same repo, twice:
apps/loopover-ui/src/components/site/keyboard-shortcuts.tsx(lines 80-84) andapps/loopover-ui/src/components/site/app-shell.tsx(lines 129-131) both guard their own global keydown handlers with anisTyping()-style check before acting:sidebar.tsx's handler has no equivalent guard.Requirements
isTyping(event.target)-style guard (checkingtagName === "INPUT" | "TEXTAREA" | "SELECT"orisContentEditable) toSidebarProvider'shandleKeyDown, and return early (without callingtoggleSidebar()orpreventDefault()) when the event target is a form field or contenteditable element — mirroringkeyboard-shortcuts.tsx'sisTypinghelper exactly, not a differently-shaped check.metaKey/ctrlKey+key === SIDEBAR_KEYBOARD_SHORTCUTcondition unchanged for the non-typing case.toggleSidebar's own behavior, the cookie-persistence logic, or any other part ofSidebarProvider.Deliverables
isTyping-equivalent guard added toSidebarProvider'shandleKeyDowninpackages/loopover-ui-kit/src/components/sidebar.tsxsidebar.test.tsx— none exists today) asserting: (a)Cmd/Ctrl+Bwhile focus is on a plain<div>/document.bodytoggles the sidebar, and (b)Cmd/Ctrl+Bwhile focus is on an<input>/<textarea>/ acontentEditableelement does not toggle the sidebar and does not callpreventDefault()Test Coverage Requirements
packages/loopover-ui-kitis not in the rootvitest.config.ts'scoverage.includeand is not Codecov-gated — still add the regression test above (this package's own suite must run and pass per itsvitest.config.ts's stated acceptance bar).Expected Outcome
Typing "b" while holding Cmd/Ctrl inside any text input, textarea, or contenteditable element on a page using
SidebarProviderno longer toggles the sidebar or blocks the browser's native Bold shortcut — matching the guard already applied to the other two global keyboard-shortcut handlers in this repo.Links & Resources
apps/loopover-ui/src/components/site/keyboard-shortcuts.tsx:80-84(theisTypinghelper to mirror)apps/loopover-ui/src/components/site/app-shell.tsx:129-131(a second, independent instance of the same guard)packages/loopover-ui-kit/src/components/sidebar.tsx:104-117(the ungated handler)