feat: optimize the quick search function

This commit is contained in:
JimmFly
2022-12-15 16:27:10 +08:00
parent 3857749811
commit 3dfae6a5ac
6 changed files with 144 additions and 83 deletions
@@ -5,6 +5,7 @@ import { Command } from 'cmdk';
export const Input = (props: {
query: string;
setQuery: Dispatch<SetStateAction<string>>;
setLoading: Dispatch<SetStateAction<boolean>>;
}) => {
const inputRef = useRef<HTMLInputElement>(null);
useEffect(() => {
@@ -18,7 +19,10 @@ export const Input = (props: {
<Command.Input
ref={inputRef}
value={props.query}
onValueChange={props.setQuery}
onValueChange={str => {
props.setQuery(str);
props.setLoading(true);
}}
placeholder="Quick Search..."
/>
</StyledInputContent>