diff --git a/client/src/components/ui/search.tsx b/client/src/components/ui/search.tsx index 188d6d53..2f5b1dcf 100644 --- a/client/src/components/ui/search.tsx +++ b/client/src/components/ui/search.tsx @@ -17,6 +17,7 @@ export default function Search({ className, autoFocus = false, showCloseIconAlways = false, + defaultValue = "", }: { placeholder?: string; onChange: (v: string | undefined) => void; @@ -24,8 +25,9 @@ export default function Search({ className?: HTMLDivElement["className"] | undefined; autoFocus?: HTMLInputElement["autofocus"] | undefined; showCloseIconAlways?: boolean | undefined; + defaultValue?: string | undefined; }) { - const [value, setValue] = useState(""); + const [value, setValue] = useState(defaultValue); const debouncedOnChange = useDebounce((value: string | undefined) => { onChange(value); diff --git a/client/src/containers/overview/table/toolbar/search/index.tsx b/client/src/containers/overview/table/toolbar/search/index.tsx index 84734999..b0971626 100644 --- a/client/src/containers/overview/table/toolbar/search/index.tsx +++ b/client/src/containers/overview/table/toolbar/search/index.tsx @@ -5,7 +5,7 @@ import { useGlobalFilters } from "@/app/(overview)/url-store"; import Search from "@/components/ui/search"; export default function SearchProjectsTable() { - const [, setFilters] = useGlobalFilters(); + const [{ keyword }, setFilters] = useGlobalFilters(); const handleSearch = async ( v: Parameters["onChange"]>[0], @@ -18,6 +18,7 @@ export default function SearchProjectsTable() { placeholder="Search project" onChange={handleSearch} className="flex-1" + defaultValue={keyword} /> ); }