From 51c3a69be7ccab7798a0bc61f26706ab41022b87 Mon Sep 17 00:00:00 2001 From: dealerweb Date: Thu, 2 Jul 2026 14:18:31 +0200 Subject: [PATCH] Fix: don't toggle mailbox subfolders on Arrow keys while typing The sidebar registers a global window keydown listener that expands/collapses the selected mailbox's subfolders on ArrowLeft/ArrowRight. It didn't check where focus was, so pressing Left/Right while typing in a new email (the contentEditable composer, the subject field, search, etc.) toggled the inbox's subfolders open/closed. Bail out of the handler when the event target is an editable element (INPUT/TEXTAREA/SELECT/contentEditable). Folder-tree arrow navigation still works when focus isn't in an input. --- components/layout/sidebar.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/components/layout/sidebar.tsx b/components/layout/sidebar.tsx index 02268d8e..9671f226 100644 --- a/components/layout/sidebar.tsx +++ b/components/layout/sidebar.tsx @@ -853,6 +853,20 @@ export function Sidebar({ useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { + // Don't hijack Arrow keys while the user is typing. This is a global + // window listener, so without this guard typing in a new email (the + // contentEditable composer, the subject field, search, etc.) toggled the + // selected mailbox's subfolders open/closed on ArrowLeft/ArrowRight. + const target = e.target as HTMLElement | null; + if ( + target && + (target.tagName === 'INPUT' || + target.tagName === 'TEXTAREA' || + target.tagName === 'SELECT' || + target.isContentEditable) + ) { + return; + } if (!selectedMailbox || isCollapsed) return; const findNode = (nodes: MailboxNode[]): MailboxNode | null => {