Skip to content

Commit

Permalink
reflects search value from URL in table search
Browse files Browse the repository at this point in the history
  • Loading branch information
andresgnlez committed Dec 10, 2024
1 parent d680ce9 commit bce2e08
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion client/src/components/ui/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ export default function Search({
className,
autoFocus = false,
showCloseIconAlways = false,
defaultValue = "",
}: {
placeholder?: string;
onChange: (v: string | undefined) => void;
onClose?: () => void;
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ComponentProps<typeof Search>["onChange"]>[0],
Expand All @@ -18,6 +18,7 @@ export default function SearchProjectsTable() {
placeholder="Search project"
onChange={handleSearch}
className="flex-1"
defaultValue={keyword}
/>
);
}

0 comments on commit bce2e08

Please sign in to comment.