Skip to content

Commit

Permalink
scroll to the top on state change (#615)
Browse files Browse the repository at this point in the history
* scroll to the top on stte change

* update pagination
  • Loading branch information
steveoni authored Dec 18, 2024
1 parent 0ac2fb0 commit e9981cf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 10 additions & 1 deletion deployment/frontend/src/components/datasets/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export default function Pagination({
} else {
setCurrentPage(Math.ceil(query.page.start / query.page.rows) + 1)
}
if(window) {
window.scrollTo({top: 0, behavior: 'smooth'})
}
}, [query.page.rows])

/*
Expand All @@ -65,10 +68,16 @@ export default function Pagination({
...prev,
page: { ...prev.page, start: destination },
}))

if(window) {
window.scrollTo({top: 0, behavior: 'smooth'})
}
}, [currentPage, query.page.rows])



return (
<div className="flex items-center justify-between bg-white py-3">
<div className="flex items-center justify-between bg-white py-3 overflow-x-auto">
<div className="flex sm:flex-1 sm:items-center sm:justify-between mx-auto">
<div>
<nav
Expand Down
3 changes: 3 additions & 0 deletions deployment/frontend/src/pages/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ export default function SearchPage(
shallow: true,
}
)
if(window) {
window.scrollTo({top: 0, behavior: 'smooth'})
}
}, [filters, query.page, query.sortBy])
const links = [{ label: 'Search', url: '/search', current: true }]

Expand Down

0 comments on commit e9981cf

Please sign in to comment.