Skip to content

Commit

Permalink
Fix 0-based MUI vs. 1-based API
Browse files Browse the repository at this point in the history
  • Loading branch information
bbecquet committed Dec 30, 2021
1 parent ee47ff7 commit 1984724
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions packages/react-ui/src/widgets/TableWidgetUI/TableWidgetUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ function TableWidgetUI({
};

const handleChangePage = (_event, newPage) => {
onSetPage(newPage);
onSetPage(newPage + 1);
};

const handleChangeRowsPerPage = (event) => {
onSetRowsPerPage(parseInt(event.target.value, 10));
onSetPage(0);
onSetPage(1);
};

return (
Expand All @@ -110,7 +110,7 @@ function TableWidgetUI({
component='div'
count={totalCount}
rowsPerPage={rowsPerPage}
page={page}
page={page - 1}
onPageChange={handleChangePage}
onRowsPerPageChange={handleChangeRowsPerPage}
/>
Expand Down
2 changes: 1 addition & 1 deletion packages/react-widgets/src/widgets/TableWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function TableWidget({
onError
}) {
const [rowsPerPage, setRowsPerPage] = useState(10);
const [page, setPage] = useState(0);
const [page, setPage] = useState(1);
const [totalCount, setTotalCount] = useState(0);

const [sortBy, setSortBy] = useState(undefined);
Expand Down
2 changes: 1 addition & 1 deletion packages/react-workers/src/workers/features.worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ function getRawFeatures({
}

function applyPagination(features, { limit, page }) {
return features.slice(limit * page, limit * (page + 1));
return features.slice(limit * Math.max(0, page - 1), limit * Math.max(1, page));
}

function getFilteredFeatures(filters = {}) {
Expand Down

0 comments on commit 1984724

Please sign in to comment.