From f7bc26e40e81b652db98f39b8abdc3ff7d64cbe8 Mon Sep 17 00:00:00 2001 From: liuhao1024 Date: Sun, 21 Jun 2026 14:11:49 +0800 Subject: [PATCH] fix(desktop): prevent PageUp/PageDown from breaking chat layout When the composer contentEditable is focused, PageUp/PageDown propagate to the chat-thread scroll container and cause layout breakage: large blank area at the bottom, content shifted left, sidebar pushed off-screen. Intercept both keys in handleEditorKeyDown and preventDefault() so the browser's native scroll behaviour stays inside the single-line composer where these keys have no text-editing purpose. Fixes #49978 --- apps/desktop/src/app/chat/composer/index.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/apps/desktop/src/app/chat/composer/index.tsx b/apps/desktop/src/app/chat/composer/index.tsx index c27685fec8..5daa5d647d 100644 --- a/apps/desktop/src/app/chat/composer/index.tsx +++ b/apps/desktop/src/app/chat/composer/index.tsx @@ -695,6 +695,19 @@ export function ChatBar({ return } + // PageUp/PageDown: the composer is a single-line contentEditable — these + // keys have no text-editing purpose, and letting their default bubble to + // the browser's scroll-the-nearest-scrollable-ancestor behavior breaks the + // chat layout in the desktop pane tree (large blank area, sidebar pushed + // off-screen — #49978). Swallow the default here; the global + // conversation.scrollPageUp/Down keybind turns the intent into an + // explicit, focused-transcript page instead. + if (event.key === 'PageUp' || event.key === 'PageDown') { + event.preventDefault() + + return + } + // macOS Chinese IME (and some 3rd-party IMEs on Windows) emit Enter with // keyCode 229 (legacy VK_PROCESSKEY) while isComposing is already false. // The compositionend has fired but the keydown still carries 229, signalling