Skip to content

Commit

Permalink
fix(ai-chat): input auto focus
Browse files Browse the repository at this point in the history
  • Loading branch information
MuhammadUmer44 committed Sep 26, 2024
1 parent 0c354e2 commit 43873d9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/App/UniverseQuestion/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useEffect, useRef, useState } from 'react'
import styled from 'styled-components'
import { Flex } from '~/components/common/Flex'

import { TextareaAutosize } from '@mui/base'
import { Button } from '@mui/material'
import { useEffect, useState } from 'react'
import ArrowForwardIcon from '~/components/Icons/ArrowForwardIcon'
import ExploreIcon from '~/components/Icons/ExploreIcon'
import HelpIcon from '~/components/Icons/HelpIcon'
Expand All @@ -15,6 +15,7 @@ import { colors } from '~/utils/colors'

export const UniverseQuestion = () => {
const [question, setQuestion] = useState('')
const textAreaRef = useRef<HTMLTextAreaElement>(null)
const { fetchData, setAbortRequests, seedQuestions } = useDataStore((s) => s)
const [setBudget] = useUserStore((s) => [s.setBudget])

Expand All @@ -33,6 +34,12 @@ export const UniverseQuestion = () => {
}
}, [seedQuestions])

useEffect(() => {
if (textAreaRef.current) {
textAreaRef.current.focus()
}
}, [])

const handleSubmitQuestion = async (questionToSubmit: string) => {
if (questionToSubmit) {
resetAiSummaryAnswer()
Expand Down Expand Up @@ -85,6 +92,7 @@ export const UniverseQuestion = () => {
Ideas have shapes
<TextAreaWrapper onKeyDown={onEnterPress} py={12} tabIndex={-1}>
<StyledTextarea
ref={textAreaRef}
onChange={(e) => setQuestion(e.target.value)}
placeholder="What do you want to know?"
value={question}
Expand Down

0 comments on commit 43873d9

Please sign in to comment.