Skip to content

Commit 581f173

Browse files
Revert "TableBody: Fix range selection when lazy loading is enabled (#7799)" (#8028)
This reverts commit 11b653e.
1 parent 9eba697 commit 581f173

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

components/lib/datatable/TableBody.js

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,6 @@ export const TableBody = React.memo(
199199
return options ? options[option] : null;
200200
};
201201

202-
const getProcessedDataIndex = (rowIndex) => {
203-
return props.lazy ? rowIndex - props.first : rowIndex;
204-
};
205-
206202
const findIndex = (collection, rowData) => {
207203
return (collection || []).findIndex((data) => equals(rowData, data));
208204
};
@@ -355,17 +351,15 @@ export const TableBody = React.memo(
355351
let rangeEnd;
356352

357353
const isAllowCellSelection = allowCellSelection();
358-
const rangeRowIndexInProcessedData = getProcessedDataIndex(rangeRowIndex.current);
359-
const anchorRowIndexInProcessedData = getProcessedDataIndex(anchorRowIndex.current);
360-
361-
if (rangeRowIndexInProcessedData > anchorRowIndexInProcessedData) {
362-
rangeStart = anchorRowIndexInProcessedData;
363-
rangeEnd = rangeRowIndexInProcessedData;
364-
} else if (rangeRowIndexInProcessedData < anchorRowIndexInProcessedData) {
365-
rangeStart = rangeRowIndexInProcessedData;
366-
rangeEnd = anchorRowIndexInProcessedData;
354+
355+
if (rangeRowIndex.current > anchorRowIndex.current) {
356+
rangeStart = anchorRowIndex.current;
357+
rangeEnd = rangeRowIndex.current;
358+
} else if (rangeRowIndex.current < anchorRowIndex.current) {
359+
rangeStart = rangeRowIndex.current;
360+
rangeEnd = anchorRowIndex.current;
367361
} else {
368-
rangeStart = rangeEnd = rangeRowIndexInProcessedData;
362+
rangeStart = rangeEnd = rangeRowIndex.current;
369363
}
370364

371365
return isAllowCellSelection ? selectRangeOnCell(event, rangeStart, rangeEnd) : selectRangeOnRow(event, rangeStart, rangeEnd);
@@ -410,7 +404,7 @@ export const TableBody = React.memo(
410404
for (let i = rowRangeStart; i <= rowRangeEnd; i++) {
411405
let rowData = value[i];
412406
let columns = props.columns;
413-
let rowIndex = props.lazy ? i + props.first : i;
407+
let rowIndex = props.paginator ? i + props.first : i;
414408

415409
for (let j = cellRangeStart; j <= cellRangeEnd; j++) {
416410
let field = getColumnProp(columns[j], 'field');
@@ -941,7 +935,7 @@ export const TableBody = React.memo(
941935
};
942936

943937
const createGroupHeader = (rowData, rowIndex, expanded, colSpan) => {
944-
if (isSubheaderGrouping && shouldRenderRowGroupHeader(props.value, rowData, getProcessedDataIndex(rowIndex))) {
938+
if (isSubheaderGrouping && shouldRenderRowGroupHeader(props.value, rowData, rowIndex - props.first)) {
945939
const style = rowGroupHeaderStyle();
946940
const toggler = props.expandableRowGroups && (
947941
<RowTogglerButton

0 commit comments

Comments
 (0)