Skip to content

Commit

Permalink
fix(staking): fix last page getting dropped
Browse files Browse the repository at this point in the history
Also return to first page when changing page size
  • Loading branch information
cprussin committed Oct 9, 2024
1 parent a32f485 commit 02e32f2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions apps/staking/src/components/OracleIntegrityStaking/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,16 @@ const PublisherList = ({
[setYoursFirst, updatePage],
);

const updatePageSize = useCallback<typeof setPageSize>(
(newPageSize) => {
setPageSize(newPageSize);
updatePage(1);
},
[setPageSize, updatePage],
);

const numPages = useMemo(
() => Math.floor(filteredSortedPublishers.length / pageSize),
() => Math.ceil(filteredSortedPublishers.length / pageSize),
[filteredSortedPublishers, pageSize],
);

Expand Down Expand Up @@ -836,7 +844,7 @@ const PublisherList = ({
label="Page size"
options={PageSize}
selectedKey={pageSize}
onSelectionChange={setPageSize}
onSelectionChange={updatePageSize}
/>
<Paginator
currentPage={currentPage}
Expand Down

0 comments on commit 02e32f2

Please sign in to comment.