Skip to content

Search query refreshes after a couple of seconds for notes and tasks #1

@ryanbakker

Description

@ryanbakker

When searching in the tasks and notes pages, the URL changes correctly and the content updates to show the correct data. However it reverts back to a no-search state after a couple of seconds.

`const [query, setQuery] = useState("");
const router = useRouter();
const searchParams = useSearchParams();

useEffect(() => {
const delayDebounceFn = setTimeout(() => {
let newUrl = "";

  if (query) {
    newUrl = formUrlQuery({
      params: searchParams.toString(),
      key: "query",
      value: query,
    });
  } else {
    newUrl = removeKeysFromQuery({
      params: searchParams.toString(),
      keysToRemove: ["query"],
    });
  }

  router.push(newUrl, { scroll: false });
}, 300);

return () => clearTimeout(delayDebounceFn);

}, [query, searchParams, router]);`

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions