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
This commit is contained in:
Bohdan Triapitsyn
2026-07-06 00:39:49 +03:00
parent 086982c1b3
commit 81c9e6eaa2
2 changed files with 2 additions and 2 deletions
@@ -4265,6 +4265,7 @@ const ChatInputComponent: React.FC<ChatInputProps> = ({ 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<ChatInputProps> = ({ 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' });
}
@@ -544,7 +544,7 @@ export const TextSelectionMenu: React.FC<TextSelectionMenuProps> = ({ containerR
} finally {
setIsAddingToNotes(false);
}
}, [currentProjectRef, hideMenu, selectedText, selectedTextMarkdown, t]);
}, [currentProjectRef, currentSessionId, hideMenu, selectedText, selectedTextMarkdown, t]);
if (!position.show) return null;