Skip to content

Commit 78d81ae

Browse files
committed
fix(collections): update pagination pattern
1 parent daf98c6 commit 78d81ae

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

clients/web/src/components/pagination/pagination.tsx

+17-19
Original file line numberDiff line numberDiff line change
@@ -95,29 +95,27 @@ export const Pagination = ({
9595
.slice(startingPosition, endingPosition)
9696

9797
// This end link may or may not be necessary based on overflow we calculated
98-
const endLink = (
99-
<>
100-
<div className="more">
101-
<OverflowMenuIcon className="" />
102-
</div>
103-
<PageLink
104-
pagePattern={pagePattern}
105-
key={`pagination-${totalPages}`}
106-
pageNumber={totalPages}
107-
currentPage={currentPage}
108-
/>
109-
</>
110-
)
98+
const endLink = [
99+
<div key="pagination-overflow" className="more">
100+
<OverflowMenuIcon className="" />
101+
</div>,
102+
<PageLink
103+
key="pagination-end-link"
104+
pagePattern={pagePattern}
105+
pageNumber={totalPages}
106+
currentPage={currentPage}
107+
/>
108+
]
111109

112110
// Build our link array here (with possible overflow)
113-
const shownLinks = showOverflow ? [...links, endLink] : links
111+
const shownLinks = showOverflow ? [...links, ...endLink] : links
114112

115113
// We want to know if we should be activating the forward/backward based on
116114
// the position we are at in the sequence.
117115
const disableBack = currentPage === 1
118116
const disableForward = currentPage === totalPages
119-
const backLink = currentPage === 2 ? pagePattern : `${pagePattern}${currentPage - 1}`
120-
const forwardLink = disableForward ? '#' : `${pagePattern}${currentPage + 1}`
117+
const backLink = currentPage === 2 ? pagePattern : `${pagePattern}/page/${currentPage - 1}`
118+
const forwardLink = disableForward ? '#' : `${pagePattern}/page/${currentPage + 1}`
121119

122120
return showPagination ? (
123121
<>
@@ -127,7 +125,7 @@ export const Pagination = ({
127125
<ChevronLeftIcon className="" />
128126
</button>
129127
) : (
130-
<Link href={backLink}>
128+
<Link key={'pagination-backward'} href={backLink}>
131129
<button className="pagination">
132130
<ChevronLeftIcon className="" />
133131
</button>
@@ -139,7 +137,7 @@ export const Pagination = ({
139137
<ChevronRightIcon className="" />
140138
</button>
141139
) : (
142-
<Link href={forwardLink}>
140+
<Link key={'pagination-forward'} href={forwardLink}>
143141
<button className="pagination">
144142
<ChevronRightIcon className="" />
145143
</button>
@@ -161,7 +159,7 @@ const PageLink = ({
161159
currentPage: number
162160
}) => {
163161
const buttonClass = pageNumber === currentPage ? 'active' : null
164-
const href = pageNumber === 1 ? pagePattern : `${pagePattern}${pageNumber}`
162+
const href = pageNumber === 1 ? pagePattern : `${pagePattern}/page/${pageNumber}`
165163
return (
166164
<Link href={href}>
167165
<button className={cx('pagination', buttonClass)}>{pageNumber}</button>

clients/web/src/containers/collections/collections.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default function Collections({ locale, noIndex, totalResults, perPage, cu
5656
{showPagination ? (
5757
<div className="pagination-container">
5858
<Pagination
59-
pagePattern="/collections/page/"
59+
pagePattern="/collections"
6060
totalResults={totalResults}
6161
currentPage={currentPage}
6262
perPageCount={perPage}
@@ -105,7 +105,7 @@ export default function Collections({ locale, noIndex, totalResults, perPage, cu
105105
{showPagination ? (
106106
<div className="pagination-container">
107107
<Pagination
108-
pagePattern="/collections/page/"
108+
pagePattern="/collections"
109109
totalResults={totalResults}
110110
currentPage={currentPage}
111111
perPageCount={perPage}

0 commit comments

Comments
 (0)