From 2caa231a5b8edad2b6af338e089405709c7af901 Mon Sep 17 00:00:00 2001 From: Tong Hau Date: Thu, 18 Jul 2024 15:27:23 +0800 Subject: [PATCH] fix(pagination): duplicate first page button --- src/Pagination/Pagination.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Pagination/Pagination.tsx b/src/Pagination/Pagination.tsx index 23543116..5097330e 100644 --- a/src/Pagination/Pagination.tsx +++ b/src/Pagination/Pagination.tsx @@ -105,7 +105,11 @@ export const Pagination: React.FC = ({ }; const renderFirstPage = () => { - const sanitizeStartPage = currentPage - Math.floor(sanitizeLimit / 2); + let sanitizeStartPage = currentPage - Math.floor(sanitizeLimit / 2); + + if (pages.length - sanitizeStartPage < limit) { + sanitizeStartPage = pages.length + 1 - limit; + } if (sanitizeStartPage > 1) { return (