diff --git a/components/ChatView/Textarea.tsx b/components/ChatView/MessageTextarea.tsx similarity index 64% rename from components/ChatView/Textarea.tsx rename to components/ChatView/MessageTextarea.tsx index cb50e13..b3eefb5 100644 --- a/components/ChatView/Textarea.tsx +++ b/components/ChatView/MessageTextarea.tsx @@ -1,17 +1,24 @@ import axios from "axios"; -import { useRef, useState } from "react"; +import { useEffect, useRef, useState } from "react"; +import TextareaAutosize from "react-textarea-autosize"; import { useChatStore, useMessageStore, useUserStore } from "../../store"; import { UserRole } from "../../types"; import { generateUUID } from "../../utils"; import Icon from "../Icon"; -const Textarea = () => { +const MessageTextarea = () => { const userStore = useUserStore(); const chatStore = useChatStore(); const messageStore = useMessageStore(); const [value, setValue] = useState(""); const textareaRef = useRef(null); + useEffect(() => { + if (textareaRef.current) { + textareaRef.current.focus(); + } + }, []); + const handleChange = (e: React.ChangeEvent) => { setValue(e.target.value); }; @@ -49,11 +56,20 @@ const Textarea = () => { }; return ( -
-