From fa42592b950c66ad83e162aea4c782dfa65de862 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Sun, 13 Jul 2025 08:10:15 -0600 Subject: [PATCH] Focus input after chat comes in --- .../ChatContainer/ChatContent/ChatInput/ChatInput.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatInput/ChatInput.tsx b/apps/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatInput/ChatInput.tsx index c311a9317..ec212b441 100644 --- a/apps/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatInput/ChatInput.tsx +++ b/apps/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatInput/ChatInput.tsx @@ -1,4 +1,4 @@ -import React, { type ChangeEvent, useMemo, useRef, useState } from 'react'; +import React, { type ChangeEvent, useEffect, useMemo, useRef, useState } from 'react'; import { InputTextAreaButton } from '@/components/ui/inputs/InputTextAreaButton'; import { useMemoizedFn } from '@/hooks'; import { cn } from '@/lib/classMerge'; @@ -32,6 +32,14 @@ export const ChatInput: React.FC = React.memo(() => { setInputValue(e.target.value); }); + useEffect(() => { + if (hasChat) { + requestAnimationFrame(() => { + textAreaRef.current?.focus(); + }); + } + }, [hasChat, textAreaRef]); + return (