From 96d48722ecc63f19fee9c29d144451c1ce38b09b Mon Sep 17 00:00:00 2001 From: Oksamies Date: Wed, 28 Aug 2024 13:33:25 +0300 Subject: [PATCH] Add minimum refresh time for search inputs --- .../app/commonComponents/PackageSearch/PackageSearch.tsx | 4 +++- apps/cyberstorm-remix/app/communities/communities.tsx | 4 +++- .../cyberstorm/src/components/ValidationBar/ValidationBar.tsx | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/cyberstorm-remix/app/commonComponents/PackageSearch/PackageSearch.tsx b/apps/cyberstorm-remix/app/commonComponents/PackageSearch/PackageSearch.tsx index 3aadf0f3a..e1f6a1ddf 100644 --- a/apps/cyberstorm-remix/app/commonComponents/PackageSearch/PackageSearch.tsx +++ b/apps/cyberstorm-remix/app/commonComponents/PackageSearch/PackageSearch.tsx @@ -90,7 +90,9 @@ export function PackageSearch(props: Props) { .filter((c) => c.selection === "exclude") .map((c) => c.id); - const [debouncedSearchValue] = useDebounce(searchValue, 300); + const [debouncedSearchValue] = useDebounce(searchValue, 300, { + maxWait: 300, + }); const deferredCreatedAfter = useDeferredValue(createdAfter); const deferredCreatedBefore = useDeferredValue(createdBefore); diff --git a/apps/cyberstorm-remix/app/communities/communities.tsx b/apps/cyberstorm-remix/app/communities/communities.tsx index 74e0f4c9f..4f2cad8e4 100644 --- a/apps/cyberstorm-remix/app/communities/communities.tsx +++ b/apps/cyberstorm-remix/app/communities/communities.tsx @@ -100,7 +100,9 @@ export default function CommunitiesPage() { const [searchValue, setSearchValue] = useState( searchParams.getAll("search").join(" ") ); - const [debouncedSearchValue] = useDebounce(searchValue, 300); + const [debouncedSearchValue] = useDebounce(searchValue, 300, { + maxWait: 300, + }); useEffect(() => { if (debouncedSearchValue === "") { diff --git a/packages/cyberstorm/src/components/ValidationBar/ValidationBar.tsx b/packages/cyberstorm/src/components/ValidationBar/ValidationBar.tsx index 196ddba2d..1d8bb3ddf 100644 --- a/packages/cyberstorm/src/components/ValidationBar/ValidationBar.tsx +++ b/packages/cyberstorm/src/components/ValidationBar/ValidationBar.tsx @@ -71,7 +71,9 @@ function ValidationElement(props: { message: string; }>({ status: "waiting", message: "Waiting for input" }); - const [valArgs] = useDebounce({ ...validator.args }, 300); + const [valArgs] = useDebounce({ ...validator.args }, 300, { + maxWait: 300, + }); const getValidation = () => usePromise(validator.validationFunc, [valArgs]);