Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(addon-table): fix calculating start page #9980

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class TuiTablePagination {
}

protected get start(): number {
return this.page * this.size;
return Math.min(this.page * this.size, Math.max(this.total - this.size, 0));
}

protected get end(): number {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
documentationPropertyName="total"
documentationPropertyType="number"
[(documentationPropertyValue)]="total"
(documentationPropertyValueChange)="totalChange($event)"
>
Total amount of items/lines in the table.
</ng-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ export default class Page {
this.page = page;
this.size = size;
}

protected totalChange(total: number): void {
this.total = total;
this.size = Math.min(this.size, Math.max(total, 1));
}
}
Loading