diff --git a/ui/v2.5/src/hooks/ListHook.tsx b/ui/v2.5/src/hooks/ListHook.tsx index 6108c9acb..c1485b157 100644 --- a/ui/v2.5/src/hooks/ListHook.tsx +++ b/ui/v2.5/src/hooks/ListHook.tsx @@ -175,6 +175,14 @@ const RenderList = < const result = useData(filter); const totalCount = getCount(result); const items = getData(result); + const pages = Math.ceil(totalCount / filter.itemsPerPage); + + // handle case where page is more than there are pages + useEffect(() => { + if (pages > 0 && filter.currentPage > pages) { + onChangePage(pages); + } + }, [pages, filter.currentPage, onChangePage]); useEffect(() => { Mousetrap.bind("right", () => { @@ -364,8 +372,6 @@ const RenderList = < return; } - const pages = Math.ceil(totalCount / filter.itemsPerPage); - return ( <> {renderPagination()}