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 { FileType, KnowledgeBase } from '@renderer/types'
|
||||
import { Input, List, Modal, Spin, Typography } from 'antd'
|
||||
import { useState } from 'react'
|
||||
import { useRef, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
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 [searchKeyword, setSearchKeyword] = useState('')
|
||||
const { t } = useTranslation()
|
||||
const searchInputRef = useRef<any>(null)
|
||||
|
||||
const handleSearch = async (value: string) => {
|
||||
if (!value.trim()) {
|
||||
@ -91,6 +92,7 @@ const PopupContainer: React.FC<Props> = ({ base, resolve }) => {
|
||||
onOk={onOk}
|
||||
onCancel={onCancel}
|
||||
afterClose={onClose}
|
||||
afterOpenChange={(visible) => visible && searchInputRef.current?.focus()}
|
||||
width={800}
|
||||
footer={null}
|
||||
centered
|
||||
@ -102,6 +104,7 @@ const PopupContainer: React.FC<Props> = ({ base, resolve }) => {
|
||||
enterButton
|
||||
size="large"
|
||||
onSearch={handleSearch}
|
||||
ref={searchInputRef}
|
||||
/>
|
||||
<ResultsContainer>
|
||||
{loading ? (
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user