autofocus textarea (#103)

This commit is contained in:
Tony
2023-03-23 19:01:35 +00:00
committed by GitHub
parent 42c48f290f
commit 7ce2d5ec2c
2 changed files with 8 additions and 3 deletions
+3 -3
View File
@@ -7,14 +7,13 @@ interface Props {
onSend: (message: Message) => void;
model: OpenAIModel;
stopConversationRef: MutableRefObject<boolean>;
textareaRef: MutableRefObject<HTMLTextAreaElement | null>;
}
export const ChatInput: FC<Props> = ({ onSend, messageIsStreaming, model, stopConversationRef }) => {
export const ChatInput: FC<Props> = ({ onSend, messageIsStreaming, model, stopConversationRef, textareaRef }) => {
const [content, setContent] = useState<string>();
const [isTyping, setIsTyping] = useState<boolean>(false);
const textareaRef = useRef<HTMLTextAreaElement>(null);
const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
const value = e.target.value;
const maxLength = model.id === OpenAIModelID.GPT_3_5 ? 12000 : 24000;
@@ -68,6 +67,7 @@ export const ChatInput: FC<Props> = ({ onSend, messageIsStreaming, model, stopCo
}
}, [content]);
function handleStopConversation() {
stopConversationRef.current = true;
setTimeout(() => {