From 097000c9da8d7701be585ed321802bd6af6add9d Mon Sep 17 00:00:00 2001 From: James Grugett Date: Thu, 18 Aug 2022 11:23:16 -0500 Subject: [PATCH] Don't scroll to top on search change except on home --- web/components/contract-search.tsx | 4 +++- web/pages/home.tsx | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/web/components/contract-search.tsx b/web/components/contract-search.tsx index 11d65a13..ebcba985 100644 --- a/web/components/contract-search.tsx +++ b/web/components/contract-search.tsx @@ -91,6 +91,7 @@ export function ContractSearch(props: { headerClassName?: string useQuerySortLocalStorage?: boolean useQuerySortUrlParams?: boolean + isWholePage?: boolean }) { const { user, @@ -105,6 +106,7 @@ export function ContractSearch(props: { headerClassName, useQuerySortLocalStorage, useQuerySortUrlParams, + isWholePage, } = props const [numPages, setNumPages] = useState(1) @@ -139,7 +141,7 @@ export function ContractSearch(props: { setNumPages(results.nbPages) if (freshQuery) { setPages([newPage]) - window.scrollTo(0, 0) + if (isWholePage) window.scrollTo(0, 0) } else { setPages((pages) => [...pages, newPage]) } diff --git a/web/pages/home.tsx b/web/pages/home.tsx index 8153baea..e61d5c32 100644 --- a/web/pages/home.tsx +++ b/web/pages/home.tsx @@ -45,6 +45,7 @@ const Home = (props: { auth: { user: User } | null }) => { // Update the url without switching pages in Nextjs. history.pushState(null, '', `/${c.creatorUsername}/${c.slug}`) }} + isWholePage />