Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ryanbakker opened this issue Jan 9, 2024 · 0 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@ryanbakker
Copy link
Owner

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]);`

@ryanbakker ryanbakker added bug Something isn't working help wanted Extra attention is needed labels Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant