diff --git a/src/components/Menu/ChatHistoryList.tsx b/src/components/Menu/ChatHistoryList.tsx index 859120b..14513d9 100644 --- a/src/components/Menu/ChatHistoryList.tsx +++ b/src/components/Menu/ChatHistoryList.tsx @@ -1,4 +1,4 @@ -import React, { MouseEventHandler, useEffect, useState } from 'react'; +import React, { useEffect, useRef, useState } from 'react'; import useStore from '@store/store'; import ChatIcon from '@icon/ChatIcon'; @@ -69,6 +69,7 @@ const ChatHistory = ({ const [isDelete, setIsDelete] = useState(false); const [isEdit, setIsEdit] = useState(false); const [_title, _setTitle] = useState(title); + const inputRef = useRef(null); const active = currentChatIndex === chatIndex; @@ -96,6 +97,10 @@ const ChatHistory = ({ setIsEdit(false); }; + useEffect(() => { + if (inputRef && inputRef.current) inputRef.current.focus(); + }, [isEdit]); + return ( { _setTitle(e.target.value); }} + ref={inputRef} /> ) : ( _title )} -
+ {isEdit || ( +
+ )}
{active && (