Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Pagination and order of rows malfunction if default selected Id is not on page 1 #9651

Merged
merged 2 commits into from
May 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions frontend/src/Editor/Components/Table/Table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,7 @@ export function Table({
);
}
}, [JSON.stringify(changeSet)]);

useEffect(() => {
if (
allowSelection &&
Expand All @@ -939,20 +940,22 @@ export function Table({
) {
const preSelectedRowDetails = getDetailsOfPreSelectedRow();
if (_.isEmpty(preSelectedRowDetails)) return;

const selectedRow = preSelectedRowDetails?.original ?? {};
const selectedRowIndex = preSelectedRowDetails?.index ?? null;
const selectedRowId = preSelectedRowDetails?.id ?? null;
const pageNumber = Math.floor(selectedRowId / rowsPerPage) + 1;
const pageNumber = Math.floor(selectedRowIndex / rowsPerPage) + 1;

preSelectRow.current = true;
if (highlightSelectedRow) {
setExposedVariables({ selectedRow: selectedRow, selectedRowId: selectedRowId });
setExposedVariables({ selectedRow: selectedRow, selectedRowId });
toggleRowSelected(selectedRowId, true);
mergeToTableDetails({ selectedRow: selectedRow, selectedRowId: selectedRowId });
mergeToTableDetails({ selectedRow: selectedRow, selectedRowId });
} else {
toggleRowSelected(selectedRowId, true);
}
if (pageIndex >= 0 && pageNumber !== pageIndex + 1) {
gotoPage(pageNumber - 1);
setPaginationInternalPageIndex(pageNumber);
}
}

Expand Down
Loading