Skip to content

Commit

Permalink
Add minimum refresh time for search inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Oksamies committed Aug 28, 2024
1 parent 6d9611d commit 96d4872
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion apps/cyberstorm-remix/app/communities/communities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 === "") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down

0 comments on commit 96d4872

Please sign in to comment.