@@ -91,9 +91,9 @@ const Element = ({
91
91
totalResults,
92
92
onPageChange,
93
93
options,
94
+ maxTotalResults,
94
95
...props
95
96
} ) => {
96
- const pages = Math . ceil ( totalResults / currentSize ) ;
97
97
const boundaryRangeCount = options . boundaryRangeCount ;
98
98
const siblingRangeCount = options . siblingRangeCount ;
99
99
const showEllipsis = options . showEllipsis ;
@@ -103,6 +103,10 @@ const Element = ({
103
103
const showNext = options . showNext ;
104
104
const size = options . size ;
105
105
106
+ const maxTotalPages = Math . floor ( maxTotalResults / currentSize ) ;
107
+ const pages = Math . ceil ( totalResults / currentSize ) ;
108
+ const totalDisplayedPages = Math . min ( pages , maxTotalPages ) ;
109
+
106
110
const { buildUID } = useContext ( AppContext ) ;
107
111
if ( currentPage > pages ) onPageChange ( pages ) ;
108
112
@@ -117,7 +121,7 @@ const Element = ({
117
121
>
118
122
< Paginator
119
123
activePage = { currentPage }
120
- totalPages = { pages }
124
+ totalPages = { totalDisplayedPages }
121
125
onPageChange = { ( _ , { activePage } ) => onPageChange ( activePage ) }
122
126
boundaryRange = { boundaryRangeCount }
123
127
siblingRange = { siblingRangeCount }
@@ -140,11 +144,13 @@ Element.propTypes = {
140
144
onPageChange : PropTypes . func . isRequired ,
141
145
options : PropTypes . object ,
142
146
overridableId : PropTypes . string ,
147
+ maxTotalResults : PropTypes . number ,
143
148
} ;
144
149
145
150
Element . defaultProps = {
146
151
options : { } ,
147
152
overridableId : "" ,
153
+ maxTotalResults : 10000 ,
148
154
} ;
149
155
150
156
export default Overridable . component ( "Pagination" , Pagination ) ;
0 commit comments