File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ export default function AIAgent() {
2525 const [ isChatOpen , setIsChatOpen ] = useState < boolean > ( true ) ;
2626
2727 // Refs to store DOM elements
28+ const inputRef = useRef < HTMLInputElement | null > ( null ) ;
2829 const chatDivRef = useRef < HTMLElement | null > ( null ) ;
2930 const chatWindowRef = useRef < HTMLElement | null > ( null ) ;
3031 const chatFABRef = useRef < HTMLElement | null > ( null ) ;
@@ -252,10 +253,17 @@ export default function AIAgent() {
252253 className = "absolute left-0 z-10 ml-4 h-6 w-6 text-[#3276F5]"
253254 />
254255 < input
256+ ref = { inputRef }
255257 type = "text"
256258 className = "z-0 h-[52px] w-full max-w-7xl rounded-lg bg-white p-2 pr-12 pl-12 text-gray-800 placeholder:text-gray-400"
257259 value = { text }
258260 onChange = { ( { target } ) => setText ( target . value ) }
261+ onKeyDown = { ( e ) => {
262+ if ( e . key === "Enter" && ! e . shiftKey ) {
263+ e . preventDefault ( ) ;
264+ handleSubmit ( text ) ;
265+ }
266+ } }
259267 aria-describedby = "Ask me about services, success stories, or your challenges"
260268 placeholder = "Ask me about services, success stories, or your challenges"
261269 />
@@ -285,7 +293,10 @@ export default function AIAgent() {
285293 < Button
286294 key = { id }
287295 className = "rounded-md border border-white bg-transparent hover:cursor-pointer"
288- onClick = { ( ) => setText ( text ) } >
296+ onClick = { ( ) => {
297+ setText ( text ) ;
298+ inputRef . current ?. focus ( ) ;
299+ } } >
289300 { text }
290301 </ Button >
291302 ) ) }
You can’t perform that action at this time.
0 commit comments