Skip to content

Commit

Permalink
[Lens] Table shows extra rows when embedded on a dashboard (elastic#1…
Browse files Browse the repository at this point in the history
…47925)

## Summary

Fixes: elastic#147922

previously we set `-1` as `pageIndex` if we have empty data, but in this
case it should be `0`.
  • Loading branch information
VladLasitsa authored and simianhacker committed Dec 22, 2022
1 parent 2016faf commit 282befa
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ export const DatatableComponent = (props: DatatableRenderProps) => {

useEffect(() => {
if (!pagination?.pageIndex && !pagination?.pageSize) return;
const lastPageIndex = Math.ceil(firstLocalTable.rows.length / pagination.pageSize) - 1;
const lastPageIndex = firstLocalTable.rows.length
? Math.ceil(firstLocalTable.rows.length / pagination.pageSize) - 1
: 0;
/**
* When the underlying data changes, there might be a case when actual pagination page
* doesn't exist anymore - if the number of rows has decreased.
Expand Down

0 comments on commit 282befa

Please sign in to comment.