Skip to content

Commit 611e6cc

Browse files
committed
Feature: Allow range selection over multiple pages
1 parent 3c88678 commit 611e6cc

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

components/lib/datatable/TableBody.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import { localeOption } from '../api/Api';
33
import { ColumnBase } from '../column/ColumnBase';
4-
import { useMergeProps, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks';
4+
import { useMergeProps, useUnmountEffect } from '../hooks/Hooks';
55
import { DomHandler, ObjectUtils } from '../utils/Utils';
66
import { BodyRow } from './BodyRow';
77
import { RowTogglerButton } from './RowTogglerButton';
@@ -167,7 +167,7 @@ export const TableBody = React.memo(
167167
};
168168

169169
const allowRangeSelection = (event) => {
170-
return isMultipleSelection() && event.originalEvent.shiftKey && anchorRowIndex.current !== null;
170+
return isMultipleSelection() && event.originalEvent.shiftKey && anchorRowIndex.current !== null && (anchorRowFirst.current === props.first || (props.multiPageRangeSelection && !props.lazy));
171171
};
172172

173173
const allowRowSelection = () => {
@@ -882,12 +882,6 @@ export const TableBody = React.memo(
882882
}
883883
});
884884

885-
useUpdateEffect(() => {
886-
if (props.paginator && isMultipleSelection()) {
887-
anchorRowIndex.current = null;
888-
}
889-
}, [props.first]);
890-
891885
useUnmountEffect(() => {
892886
if (props.dragSelection) {
893887
unbindDragSelectionEvents();

components/lib/datatable/datatable.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,10 @@ interface DataTableBaseProps<TValue extends DataTableValueArray> extends Omit<Re
12481248
* An array of SortMeta objects to sort the data by default in multiple sort mode.
12491249
*/
12501250
multiSortMeta?: DataTableSortMeta[] | null | undefined;
1251+
/**
1252+
* Defines whether a range selection can cover multiple pages.
1253+
*/
1254+
multiPageRangeSelection?: boolean;
12511255
/**
12521256
* Number of page links to display.
12531257
* @defaultValue 5

0 commit comments

Comments
 (0)