Skip to content

Commit

Permalink
fix(Search): Close quicksearch on route change
Browse files Browse the repository at this point in the history
  • Loading branch information
qgerome committed Oct 7, 2022
1 parent ecedf4b commit 1b55be8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/catalog/features/Quicksearch/Quicksearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Dialog from "core/components/Dialog";
import Link from "core/components/Link";
import useDebounce from "core/hooks/useDebounce";
import { useTranslation } from "next-i18next";
import { useRouter } from "next/router";
import { useEffect, useState } from "react";
import SearchInput from "../SearchInput";
import SearchResult, { SearchResultProps } from "../SearchResult";
Expand All @@ -17,12 +18,17 @@ const Quicksearch = (props: QuicksearchProps) => {
const { open = false, onClose, renderActions } = props;
const [queryString, setQueryString] = useState("");
const { t } = useTranslation();
const router = useRouter();
const debouncedQueryString = useDebounce(queryString, 120);
const { results, loading } = useSearch({
query: debouncedQueryString,
perPage: 10,
});

useEffect(() => {
onClose();
}, [router.pathname, onClose]);

useEffect(() => {
if (!open) {
setQueryString("");
Expand Down

0 comments on commit 1b55be8

Please sign in to comment.