From 834334c082f9a47b456054774354c4e9ca379880 Mon Sep 17 00:00:00 2001 From: Jim Bumgardner Date: Thu, 15 Aug 2024 14:00:18 -0700 Subject: [PATCH 1/2] Pagination display fix. --- components/pagination/CHANGELOG.md | 6 ++++++ components/pagination/dist/index.js | 4 +++- components/pagination/package.json | 2 +- components/pagination/src/template.js | 4 +++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/components/pagination/CHANGELOG.md b/components/pagination/CHANGELOG.md index 3b647343..8ab237f5 100644 --- a/components/pagination/CHANGELOG.md +++ b/components/pagination/CHANGELOG.md @@ -1,5 +1,11 @@ # Pagination changelog +## 2.0.3 +- 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..d0747bfe 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,7 @@ 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..3cae179c 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,7 @@ 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) : ''} From 074bd78f56289b8c78d083e3dbc7239031c1ea0e Mon Sep 17 00:00:00 2001 From: Jim Bumgardner Date: Wed, 21 Aug 2024 11:46:15 -0700 Subject: [PATCH 2/2] White space tweaks. Fixed version number in changelog. --- components/pagination/CHANGELOG.md | 2 +- components/pagination/dist/index.js | 6 ++++-- components/pagination/src/template.js | 6 ++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/components/pagination/CHANGELOG.md b/components/pagination/CHANGELOG.md index 8ab237f5..7fc7af55 100644 --- a/components/pagination/CHANGELOG.md +++ b/components/pagination/CHANGELOG.md @@ -1,6 +1,6 @@ # Pagination changelog -## 2.0.3 +## 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 diff --git a/components/pagination/dist/index.js b/components/pagination/dist/index.js index d0747bfe..3b8b6702 100644 --- a/components/pagination/dist/index.js +++ b/components/pagination/dist/index.js @@ -35,7 +35,7 @@ function templateHTML(next, previous, page, currentPage, totalPages) { ${currentPage > 2 ? pageListItem(page, 1) : ''} - ${currentPage > 4 ? pageOverflow() : ''} + ${currentPage > 4 ? pageOverflow() : ''} ${currentPage === 4 ? pageListItem(page, 2) : ''} ${currentPage > 1 ? pageListItem(page, currentPage - 1) : ''} @@ -55,7 +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 - 3 ? pageListItem(page, totalPages - 1) : '' + } ${currentPage < totalPages - 1 ? pageListItem(page, totalPages) : ''} diff --git a/components/pagination/src/template.js b/components/pagination/src/template.js index 3cae179c..ab16e310 100644 --- a/components/pagination/src/template.js +++ b/components/pagination/src/template.js @@ -35,7 +35,7 @@ function templateHTML(next, previous, page, currentPage, totalPages) { ${currentPage > 2 ? pageListItem(page, 1) : ''} - ${currentPage > 4 ? pageOverflow() : ''} + ${currentPage > 4 ? pageOverflow() : ''} ${currentPage === 4 ? pageListItem(page, 2) : ''} ${currentPage > 1 ? pageListItem(page, currentPage - 1) : ''} @@ -55,7 +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 - 3 ? pageListItem(page, totalPages - 1) : '' + } ${currentPage < totalPages - 1 ? pageListItem(page, totalPages) : ''}