mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Keep textarea focused in GlobalChatPane after AI responds
- Focus textarea immediately after sending message (not after AI response) - Add useEffect to refocus textarea when isLoading becomes false - User can now type their next message right away without clicking
This commit is contained in:
1 parent
37071cde85
commit
361b6dae3c
1 file changed
+10
-3
@@ -164,12 +164,19 @@ export function GlobalChatPane() {
|
||||
const messageContent = input.trim();
|
||||
setInput('');
|
||||
|
||||
await sendMessage(messageContent, providerModel);
|
||||
|
||||
// Focus back on textarea
|
||||
// Focus immediately so user can keep typing
|
||||
textareaRef.current?.focus();
|
||||
|
||||
await sendMessage(messageContent, providerModel);
|
||||
}, [input, isLoading, providerModel, sendMessage]);
|
||||
|
||||
// Refocus textarea when AI finishes responding
|
||||
useEffect(() => {
|
||||
if (!isLoading && isOpen && messages.length > 0) {
|
||||
textareaRef.current?.focus();
|
||||
}
|
||||
}, [isLoading, isOpen, messages.length]);
|
||||
|
||||
const handleKeyDown = useCallback((e: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
||||
if (e.key === 'Enter' && !e.shiftKey && !isMobile) {
|
||||
e.preventDefault();
|
||||
|
||||
Reference in new issue
Block a user