From f35799c129f73f68a1cd09ff31ce7af770466512 Mon Sep 17 00:00:00 2001 From: James Grugett Date: Sat, 17 Sep 2022 14:54:55 -0500 Subject: [PATCH] Only autofocus search if no query params set --- web/pages/search.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/pages/search.tsx b/web/pages/search.tsx index 38b9760d..9c26f1a8 100644 --- a/web/pages/search.tsx +++ b/web/pages/search.tsx @@ -4,6 +4,7 @@ import { ContractSearch } from 'web/components/contract-search' import { useTracking } from 'web/hooks/use-tracking' import { useUser } from 'web/hooks/use-user' import { usePrefetch } from 'web/hooks/use-prefetch' +import { useRouter } from 'next/router' export default function Search() { const user = useUser() @@ -11,6 +12,10 @@ export default function Search() { useTracking('view search') + const { query } = useRouter() + const { q, s, p } = query + const autoFocus = !q && !s && !p + return ( @@ -18,7 +23,7 @@ export default function Search() { user={user} persistPrefix="search" useQueryUrlParam={true} - autoFocus + autoFocus={autoFocus} />