From 81c9e6eaa2926c9f47371a8ed3cc29fc4b9d9285 Mon Sep 17 00:00:00 2001 From: Bohdan Triapitsyn Date: Mon, 6 Jul 2026 00:39:49 +0300 Subject: [PATCH] fix: preserve chat composer focus on mobile keyboard Keeps the textarea reference available during mobile viewport adjustments Ensures the composer scrolls back into view after keyboard interactions Updates text selection menu dependencies to include the current session --- packages/ui/src/components/chat/ChatInput.tsx | 2 +- packages/ui/src/components/chat/message/TextSelectionMenu.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/ui/src/components/chat/ChatInput.tsx b/packages/ui/src/components/chat/ChatInput.tsx index 00d7cccf..f7c8eae2 100644 --- a/packages/ui/src/components/chat/ChatInput.tsx +++ b/packages/ui/src/components/chat/ChatInput.tsx @@ -4265,6 +4265,7 @@ const ChatInputComponent: React.FC = ({ onOpenSettings, scrollTo if (!isMobile || !isMobileExpanded || isCapacitorApp()) return; const vv = window.visualViewport; const form = composerFormRef.current; + const textarea = textareaRef.current; if (!vv || !form) return; // The form is trapped inside lower stacking contexts (the composer // wrapper's z-10), so it cannot out-stack the app header with z-index @@ -4299,7 +4300,6 @@ const ChatInputComponent: React.FC = ({ onOpenSettings, scrollTo // session and won't re-reveal the (still focused) field on its own, // which left the composer parked behind the keyboard. requestAnimationFrame(() => { - const textarea = textareaRef.current; if (textarea && document.activeElement === textarea) { textarea.scrollIntoView({ block: 'nearest' }); } diff --git a/packages/ui/src/components/chat/message/TextSelectionMenu.tsx b/packages/ui/src/components/chat/message/TextSelectionMenu.tsx index d100267b..3e5b1199 100644 --- a/packages/ui/src/components/chat/message/TextSelectionMenu.tsx +++ b/packages/ui/src/components/chat/message/TextSelectionMenu.tsx @@ -544,7 +544,7 @@ export const TextSelectionMenu: React.FC = ({ containerR } finally { setIsAddingToNotes(false); } - }, [currentProjectRef, hideMenu, selectedText, selectedTextMarkdown, t]); + }, [currentProjectRef, currentSessionId, hideMenu, selectedText, selectedTextMarkdown, t]); if (!position.show) return null;