diff --git a/package-lock.json b/package-lock.json index d030e5e..72ae5bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "reachat", - "version": "1.3.1", + "version": "1.4.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "reachat", - "version": "1.3.1", + "version": "1.4.0", "license": "Apache-2.0", "dependencies": { "@radix-ui/react-slot": "^1.1.0", @@ -14,7 +14,7 @@ "framer-motion": "^10.16.16", "katex": "^0.16.11", "mdast-util-find-and-replace": "^3.0.1", - "reablocks": "^8.4.0", + "reablocks": "^8.4.7", "react-markdown": "^9.0.1", "react-syntax-highlighter": "^15.5.0", "reakeys": "^2.0.3", @@ -15083,9 +15083,10 @@ } }, "node_modules/reablocks": { - "version": "8.4.3", - "resolved": "https://registry.npmjs.org/reablocks/-/reablocks-8.4.3.tgz", - "integrity": "sha512-Ct87zB1O7QLbcr9PtuAlx3+bmi5n2cSheZjN6ARz+fnhhat90RIngDw2u9CzJJgZUNPQ6UhozBf4S3u9y0NYbA==", + "version": "8.4.7", + "resolved": "https://registry.npmjs.org/reablocks/-/reablocks-8.4.7.tgz", + "integrity": "sha512-f0WIoT7MDNEoxqwMs6gUTpDt2gCjGR8EvzepbJrWUSNYHdVPvj2Tg5slWPdPwNGOwSDC0mhaePySNSUl5XWhkQ==", + "license": "Apache-2.0", "dependencies": { "@floating-ui/react": "^0.26.16", "@marko19907/string-to-color": "^1.0.0", diff --git a/package.json b/package.json index 4095c00..40da2b9 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "framer-motion": "^10.16.16", "katex": "^0.16.11", "mdast-util-find-and-replace": "^3.0.1", - "reablocks": "^8.4.0", + "reablocks": "^8.4.7", "react-markdown": "^9.0.1", "react-syntax-highlighter": "^15.5.0", "reakeys": "^2.0.3", diff --git a/src/ChatInput/ChatInput.tsx b/src/ChatInput/ChatInput.tsx index 80ca4df..782d8bb 100644 --- a/src/ChatInput/ChatInput.tsx +++ b/src/ChatInput/ChatInput.tsx @@ -1,5 +1,4 @@ import { - FC, useState, KeyboardEvent, ReactElement, @@ -7,7 +6,8 @@ import { ChangeEvent, useContext, forwardRef, - useImperativeHandle + useImperativeHandle, + useEffect } from 'react'; import { Button, Textarea, cn } from 'reablocks'; import SendIcon from '@/assets/send.svg?react'; @@ -62,11 +62,17 @@ export const ChatInput = forwardRef(({ stopIcon = , attachIcon }, ref) => { - const { theme, isLoading, disabled, sendMessage, stopMessage, fileUpload } = + const { theme, isLoading, disabled, sendMessage, stopMessage, fileUpload, activeSessionId } = useContext(ChatContext); const [message, setMessage] = useState(''); const inputRef = useRef(null); + useEffect(() => { + if(inputRef && inputRef.current) { + inputRef.current.focus() + } + }, [activeSessionId, inputRef]) + useImperativeHandle(ref, () => ({ focus: () => { inputRef.current?.focus(); @@ -97,7 +103,7 @@ export const ChatInput = forwardRef(({ return (