Skip to content

Commit ae887a2

Browse files
fix(addon-table): TablePagination fix incorrect calculating start page (#10623)
1 parent 06ea748 commit ae887a2

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

projects/addon-table/components/table-pagination/table-pagination.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class TuiTablePagination {
9090
}
9191

9292
protected get start(): number {
93-
return Math.min(this.page * this.size, Math.max(this.total - this.size, 0));
93+
return Math.min(this.page, Math.floor(this.total / this.size)) * this.size;
9494
}
9595

9696
protected get end(): number {

projects/demo-playwright/tests/addon-table/table-pagination/table-pagination.pw.spec.ts

+30
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,34 @@ test.describe('TablePagination', () => {
6262
'2-[sizeOptionContent]-dropdown.png',
6363
);
6464
});
65+
66+
test.describe('LinesPerPageButton', () => {
67+
test('Size is larger than total', async ({page}) => {
68+
await tuiGoto(
69+
page,
70+
'/components/table-pagination/API?total=25&size=100&page=1',
71+
);
72+
73+
const documentationPage = new TuiDocumentationPagePO(page);
74+
const tablePagination = new TuiTablePaginationPO(
75+
documentationPage.apiPageExample.locator('tui-table-pagination'),
76+
);
77+
78+
await expect(tablePagination.linesPerPageButton).toHaveText('1–25');
79+
});
80+
81+
test('Last page', async ({page}) => {
82+
await tuiGoto(
83+
page,
84+
'/components/table-pagination/API?total=25&size=10&page=2',
85+
);
86+
87+
const documentationPage = new TuiDocumentationPagePO(page);
88+
const tablePagination = new TuiTablePaginationPO(
89+
documentationPage.apiPageExample.locator('tui-table-pagination'),
90+
);
91+
92+
await expect(tablePagination.linesPerPageButton).toHaveText('21–25');
93+
});
94+
});
6595
});

0 commit comments

Comments
 (0)