Don't scroll to top on search change except on home

This commit is contained in:
James Grugett 2022-08-18 11:23:16 -05:00
parent d216b298ba
commit 097000c9da
2 changed files with 4 additions and 1 deletions

View File

@ -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])
}

View File

@ -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
/>
</Col>
<button