@@ -59,12 +59,6 @@ export function calculatePages({
59
59
* </btrix-pagination>
60
60
* ```
61
61
*
62
- * You can also disable pagination persistence via search params by setting name to `null`:
63
- * ```ts
64
- * <btrix-pagination .name=${null} totalCount="11" @page-change=${console.log}>
65
- * </btrix-pagination>
66
- * ```
67
- *
68
62
* @fires page-change {PageChangeEvent}
69
63
*/
70
64
@customElement ( "btrix-pagination" )
@@ -163,7 +157,6 @@ export class Pagination extends LitElement {
163
157
] ;
164
158
165
159
searchParams = new SearchParamsController ( this , ( params ) => {
166
- if ( this . name == null ) return ;
167
160
const page = parsePage ( params . get ( this . name ) ) ;
168
161
if ( this . _page !== page ) {
169
162
this . dispatchEvent (
@@ -192,7 +185,7 @@ export class Pagination extends LitElement {
192
185
}
193
186
194
187
@property ( { type : String } )
195
- name : string | null = "page" ;
188
+ name = "page" ;
196
189
197
190
@property ( { type : Number } )
198
191
totalCount = 0 ;
@@ -221,15 +214,13 @@ export class Pagination extends LitElement {
221
214
this . calculatePages ( ) ;
222
215
}
223
216
224
- if ( this . name != null ) {
225
- const parsedPage = parseFloat (
226
- this . searchParams . searchParams . get ( this . name ) ?? "1" ,
227
- ) ;
228
- if ( parsedPage != this . _page ) {
229
- const page = parsePage ( this . searchParams . searchParams . get ( this . name ) ) ;
230
- const constrainedPage = Math . max ( 1 , Math . min ( this . pages , page ) ) ;
231
- this . onPageChange ( constrainedPage , { dispatch : false } ) ;
232
- }
217
+ const parsedPage = parseFloat (
218
+ this . searchParams . searchParams . get ( this . name ) ?? "1" ,
219
+ ) ;
220
+ if ( parsedPage != this . _page ) {
221
+ const page = parsePage ( this . searchParams . searchParams . get ( this . name ) ) ;
222
+ const constrainedPage = Math . max ( 1 , Math . min ( this . pages , page ) ) ;
223
+ this . onPageChange ( constrainedPage , { dispatch : false } ) ;
233
224
}
234
225
235
226
// if page is out of bounds, clamp it & dispatch an event to re-fetch data
@@ -418,14 +409,10 @@ export class Pagination extends LitElement {
418
409
}
419
410
420
411
private setPage ( page : number ) {
421
- if ( this . name != null ) {
422
- if ( page === 1 ) {
423
- this . searchParams . delete ( this . name ) ;
424
- } else {
425
- this . searchParams . set ( this . name , page . toString ( ) ) ;
426
- }
412
+ if ( page === 1 ) {
413
+ this . searchParams . delete ( this . name ) ;
427
414
} else {
428
- this . _page = page ;
415
+ this . searchParams . set ( this . name , page . toString ( ) ) ;
429
416
}
430
417
}
431
418
0 commit comments