diff --git a/invokeai/frontend/web/src/features/gallery/hooks/useGalleryPagination.ts b/invokeai/frontend/web/src/features/gallery/hooks/useGalleryPagination.ts index 550027e17c..0663e5e5bc 100644 --- a/invokeai/frontend/web/src/features/gallery/hooks/useGalleryPagination.ts +++ b/invokeai/frontend/web/src/features/gallery/hooks/useGalleryPagination.ts @@ -52,7 +52,7 @@ export const useGalleryPagination = (pageButtonsPerSide: number = 2) => { // handle when total/pages decrease and user is on high page number (ie bulk removing or deleting) useEffect(() => { - if (currentPage + 1 > pages) { + if (pages && currentPage + 1 > pages) { goToLast(); } }, [currentPage, pages, goToLast]);