feat(tenders): scroll to top on pagination change
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
Smoothly scroll the page to the top when users move between tender list pages, respecting reduced-motion preferences. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -384,7 +384,7 @@ const useTenderListPresenter = () => {
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
pagination,
|
pagination,
|
||||||
handlePaginationChange,
|
handlePaginationChange: changePaginationPage,
|
||||||
buildFirstPageParams,
|
buildFirstPageParams,
|
||||||
hasNext,
|
hasNext,
|
||||||
hasPrevious,
|
hasPrevious,
|
||||||
@@ -396,6 +396,22 @@ const useTenderListPresenter = () => {
|
|||||||
error,
|
error,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const handlePaginationChange = useCallback(
|
||||||
|
(event: { selected: number }) => {
|
||||||
|
if (typeof window !== "undefined") {
|
||||||
|
const reduceMotion = window.matchMedia(
|
||||||
|
"(prefers-reduced-motion: reduce)",
|
||||||
|
).matches;
|
||||||
|
window.scrollTo({
|
||||||
|
top: 0,
|
||||||
|
behavior: reduceMotion ? "auto" : "smooth",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
changePaginationPage(event);
|
||||||
|
},
|
||||||
|
[changePaginationPage],
|
||||||
|
);
|
||||||
|
|
||||||
const shouldShowPagination = !isPending && (hasPrevious || hasNext);
|
const shouldShowPagination = !isPending && (hasPrevious || hasNext);
|
||||||
|
|
||||||
const tendersList = data?.data?.tenders ?? [];
|
const tendersList = data?.data?.tenders ?? [];
|
||||||
|
|||||||
Reference in New Issue
Block a user