diff --git a/src/tribler/ui/src/components/ui/simple-table.tsx b/src/tribler/ui/src/components/ui/simple-table.tsx index 980e3e65f0..9ca76cd7f4 100644 --- a/src/tribler/ui/src/components/ui/simple-table.tsx +++ b/src/tribler/ui/src/components/ui/simple-table.tsx @@ -140,8 +140,14 @@ function SimpleTable({ onSortingChange: setSorting, getSubRows: (row: any) => row?.subRows, getRowId: rowId, + autoResetPageIndex: false, }); + // If we're on an empty page, reset the pageIndex to 0 + if (table.getRowModel().rows.length == 0 && table.getExpandedRowModel().rows.length != 0) { + setPagination(p => ({ ...p, pageIndex: 0 })); + } + const { t } = useTranslation(); useEffect(() => { @@ -248,7 +254,7 @@ function SimpleTable({ function Pagination({ table }: React.PropsWithChildren<{ table: ReactTable }>) { const pageIndex = table.getState().pagination.pageIndex; const pageSize = table.getState().pagination.pageSize; - const rowCount = table.getCoreRowModel().rows.length; + const rowCount = table.getExpandedRowModel().rows.length; const { t } = useTranslation(); @@ -257,7 +263,15 @@ function Pagination({ table }: React.PropsWithChildren<{ table: ReactTable