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 (