Skip to content

Commit b4dec2a

Browse files
committed
Revert "allow disabling search params persistence in pagination"
This reverts commit 4ad131d. These changes will be handled by #2859 instead.
1 parent 8ea41ff commit b4dec2a

File tree

1 file changed

+11
-24
lines changed

1 file changed

+11
-24
lines changed

frontend/src/components/ui/pagination.ts

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,6 @@ export function calculatePages({
5959
* </btrix-pagination>
6060
* ```
6161
*
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-
*
6862
* @fires page-change {PageChangeEvent}
6963
*/
7064
@customElement("btrix-pagination")
@@ -163,7 +157,6 @@ export class Pagination extends LitElement {
163157
];
164158

165159
searchParams = new SearchParamsController(this, (params) => {
166-
if (this.name == null) return;
167160
const page = parsePage(params.get(this.name));
168161
if (this._page !== page) {
169162
this.dispatchEvent(
@@ -192,7 +185,7 @@ export class Pagination extends LitElement {
192185
}
193186

194187
@property({ type: String })
195-
name: string | null = "page";
188+
name = "page";
196189

197190
@property({ type: Number })
198191
totalCount = 0;
@@ -221,15 +214,13 @@ export class Pagination extends LitElement {
221214
this.calculatePages();
222215
}
223216

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 });
233224
}
234225

235226
// if page is out of bounds, clamp it & dispatch an event to re-fetch data
@@ -418,14 +409,10 @@ export class Pagination extends LitElement {
418409
}
419410

420411
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);
427414
} else {
428-
this._page = page;
415+
this.searchParams.set(this.name, page.toString());
429416
}
430417
}
431418

0 commit comments

Comments
 (0)