feat: Enhance knowledge search popup input focus behavior
This commit is contained in:
parent
3015e90925
commit
c61dde5085
@ -4,7 +4,7 @@ import { DEFAULT_KNOWLEDGE_THRESHOLD } from '@renderer/config/constant'
|
|||||||
import { getFileFromUrl, getKnowledgeBaseParams } from '@renderer/services/KnowledgeService'
|
import { getFileFromUrl, getKnowledgeBaseParams } from '@renderer/services/KnowledgeService'
|
||||||
import { FileType, KnowledgeBase } from '@renderer/types'
|
import { FileType, KnowledgeBase } from '@renderer/types'
|
||||||
import { Input, List, Modal, Spin, Typography } from 'antd'
|
import { Input, List, Modal, Spin, Typography } from 'antd'
|
||||||
import { useState } from 'react'
|
import { useRef, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
|
|
||||||
@ -25,6 +25,7 @@ const PopupContainer: React.FC<Props> = ({ base, resolve }) => {
|
|||||||
const [results, setResults] = useState<Array<ExtractChunkData & { file: FileType | null }>>([])
|
const [results, setResults] = useState<Array<ExtractChunkData & { file: FileType | null }>>([])
|
||||||
const [searchKeyword, setSearchKeyword] = useState('')
|
const [searchKeyword, setSearchKeyword] = useState('')
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
const searchInputRef = useRef<any>(null)
|
||||||
|
|
||||||
const handleSearch = async (value: string) => {
|
const handleSearch = async (value: string) => {
|
||||||
if (!value.trim()) {
|
if (!value.trim()) {
|
||||||
@ -91,6 +92,7 @@ const PopupContainer: React.FC<Props> = ({ base, resolve }) => {
|
|||||||
onOk={onOk}
|
onOk={onOk}
|
||||||
onCancel={onCancel}
|
onCancel={onCancel}
|
||||||
afterClose={onClose}
|
afterClose={onClose}
|
||||||
|
afterOpenChange={(visible) => visible && searchInputRef.current?.focus()}
|
||||||
width={800}
|
width={800}
|
||||||
footer={null}
|
footer={null}
|
||||||
centered
|
centered
|
||||||
@ -102,6 +104,7 @@ const PopupContainer: React.FC<Props> = ({ base, resolve }) => {
|
|||||||
enterButton
|
enterButton
|
||||||
size="large"
|
size="large"
|
||||||
onSearch={handleSearch}
|
onSearch={handleSearch}
|
||||||
|
ref={searchInputRef}
|
||||||
/>
|
/>
|
||||||
<ResultsContainer>
|
<ResultsContainer>
|
||||||
{loading ? (
|
{loading ? (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user