diff --git a/components/pagination/CHANGELOG.md b/components/pagination/CHANGELOG.md index 3b647343..7fc7af55 100644 --- a/components/pagination/CHANGELOG.md +++ b/components/pagination/CHANGELOG.md @@ -1,5 +1,11 @@ # Pagination changelog +## 2.0.4 +- Fixes an issue with small page counts (4,5,6,7) in which on some page numbers +an ellipsis is displayed where a single-page is missing, or both the ellipsis and +a single page are skipped leaving a gap in the sequence. New system uses ellipsis for +2 or more pages only, and displays single pages in its place, when appropriate. + ## 2.0.3 - Removed redundant package-lock.json (due to workspaces config in monorepo). This fixes vulnerability in the npm `ip` package. diff --git a/components/pagination/dist/index.js b/components/pagination/dist/index.js index 0703aec4..3b8b6702 100644 --- a/components/pagination/dist/index.js +++ b/components/pagination/dist/index.js @@ -35,7 +35,8 @@ function templateHTML(next, previous, page, currentPage, totalPages) { ${currentPage > 2 ? pageListItem(page, 1) : ''} - ${currentPage > 3 ? pageOverflow() : ''} + ${currentPage > 4 ? pageOverflow() : ''} + ${currentPage === 4 ? pageListItem(page, 2) : ''} ${currentPage > 1 ? pageListItem(page, currentPage - 1) : ''} @@ -54,6 +55,9 @@ function templateHTML(next, previous, page, currentPage, totalPages) { ${currentPage < totalPages ? pageListItem(page, currentPage + 1) : ''} ${currentPage < totalPages - 3 ? pageOverflow() : ''} + ${ + currentPage === totalPages - 3 ? pageListItem(page, totalPages - 1) : '' + } ${currentPage < totalPages - 1 ? pageListItem(page, totalPages) : ''} diff --git a/components/pagination/package.json b/components/pagination/package.json index 59fc222c..d0240970 100644 --- a/components/pagination/package.json +++ b/components/pagination/package.json @@ -1,6 +1,6 @@ { "name": "@cagov/ds-pagination", - "version": "2.0.3", + "version": "2.0.4", "description": "", "main": "dist/index.js", "customElements": "custom-elements.json", diff --git a/components/pagination/src/template.js b/components/pagination/src/template.js index 3119f7e2..ab16e310 100644 --- a/components/pagination/src/template.js +++ b/components/pagination/src/template.js @@ -35,7 +35,8 @@ function templateHTML(next, previous, page, currentPage, totalPages) { ${currentPage > 2 ? pageListItem(page, 1) : ''} - ${currentPage > 3 ? pageOverflow() : ''} + ${currentPage > 4 ? pageOverflow() : ''} + ${currentPage === 4 ? pageListItem(page, 2) : ''} ${currentPage > 1 ? pageListItem(page, currentPage - 1) : ''} @@ -54,6 +55,9 @@ function templateHTML(next, previous, page, currentPage, totalPages) { ${currentPage < totalPages ? pageListItem(page, currentPage + 1) : ''} ${currentPage < totalPages - 3 ? pageOverflow() : ''} + ${ + currentPage === totalPages - 3 ? pageListItem(page, totalPages - 1) : '' + } ${currentPage < totalPages - 1 ? pageListItem(page, totalPages) : ''}