diff --git a/components/webui/client/src/components/QueryBox/InputWithCaseSensitive/index.tsx b/components/webui/client/src/components/QueryBox/InputWithCaseSensitive/index.tsx index 567213740c..737634a1e2 100644 --- a/components/webui/client/src/components/QueryBox/InputWithCaseSensitive/index.tsx +++ b/components/webui/client/src/components/QueryBox/InputWithCaseSensitive/index.tsx @@ -1,6 +1,7 @@ import { Input, InputProps, + InputRef, } from "antd"; import CaseSensitiveToggle, {CaseSensitiveToggleProps} from "./CaseSenstiveToggle"; @@ -9,7 +10,8 @@ import CaseSensitiveToggle, {CaseSensitiveToggleProps} from "./CaseSenstiveToggl /** * Antd Input props and case sensitive toggle props with suffix omitted since set by component. */ -type InputWithCaseSensitiveProps = Omit & CaseSensitiveToggleProps; +type InputWithCaseSensitiveProps = + Omit & CaseSensitiveToggleProps & React.RefAttributes; /** * Antd Input with a built-in case sensitivity toggle. diff --git a/components/webui/client/src/pages/SearchPage/SearchControls/QueryInput/index.tsx b/components/webui/client/src/pages/SearchPage/SearchControls/QueryInput/index.tsx index 7d2b3770b5..94c6d492a4 100644 --- a/components/webui/client/src/pages/SearchPage/SearchControls/QueryInput/index.tsx +++ b/components/webui/client/src/pages/SearchPage/SearchControls/QueryInput/index.tsx @@ -6,6 +6,7 @@ import { useState, } from "react"; +import type {InputRef} from "antd"; import {Nullable} from "src/typings/common"; import QueryBox from "../../../../components/QueryBox"; @@ -28,6 +29,7 @@ const QueryInput = () => { const searchUiState = useSearchStore((state) => state.searchUiState); const [pseudoProgress, setPseudoProgress] = useState>(null); const intervalIdRef = useRef(0); + const inputRef = useRef(null); const handleCaseSensitiveChange = useCallback((newValue: boolean) => { const {updateQueryIsCaseSensitive} = useSearchStore.getState(); @@ -67,11 +69,21 @@ const QueryInput = () => { clearInterval(intervalIdRef.current); }, []); + useEffect(() => { + if ( + searchUiState === SEARCH_UI_STATE.DEFAULT || + searchUiState === SEARCH_UI_STATE.DONE + ) { + inputRef.current?.focus(); + } + }, [searchUiState]); + return (