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 {
|
||||
pagination,
|
||||
handlePaginationChange,
|
||||
handlePaginationChange: changePaginationPage,
|
||||
buildFirstPageParams,
|
||||
hasNext,
|
||||
hasPrevious,
|
||||
@@ -396,6 +396,22 @@ const useTenderListPresenter = () => {
|
||||
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 tendersList = data?.data?.tenders ?? [];
|
||||
|
||||
Reference in New Issue
Block a user