Skip to content

Commit

Permalink
fix(addon-table): fix calculating start page (#9980)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirpotekhin authored Dec 12, 2024
1 parent 9ec1e7b commit d26f32b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
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));
}
}

0 comments on commit d26f32b

Please sign in to comment.