From b718b95da7645b67c2f0a6381cc7f9a5bf9f9456 Mon Sep 17 00:00:00 2001 From: Naiyuan Qing <145280634+NevilleQingNY@users.noreply.github.com> Date: Thu, 12 Feb 2026 09:39:16 +0800 Subject: [PATCH] fix(ui): improve chat input scroll behavior - Scroll cursor into view on content changes (e.g., Shift+Enter) - Add scroll threshold and margin for better edge handling Co-Authored-By: Claude Opus 4.5 --- packages/ui/src/components/chat-input.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/ui/src/components/chat-input.tsx b/packages/ui/src/components/chat-input.tsx index fafbdfb2..9bd51fd4 100644 --- a/packages/ui/src/components/chat-input.tsx +++ b/packages/ui/src/components/chat-input.tsx @@ -47,11 +47,18 @@ export const ChatInput = forwardRef( Placeholder.configure({ placeholder }), ], immediatelyRender: false, + // Scroll cursor into view on every content change (e.g., Shift+Enter newlines) + onUpdate({ editor }) { + editor.commands.scrollIntoView(); + }, editorProps: { attributes: { class: "w-full resize-none bg-transparent px-1 py-1 text-base text-foreground outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed", }, + // Ensure cursor scrolls into view when typing near container edges + scrollThreshold: 20, + scrollMargin: 20, handleKeyDown(_view, event) { // Guard for IME composition (Chinese/Japanese input) if (event.isComposing) return false;