handle case where range select with few selected and few unselected items

select all the items in the union of two ranges
This commit is contained in:
Abhinav 2022-01-06 14:12:41 +05:30
parent 6d76611079
commit 73882919d1

View file

@ -315,9 +315,12 @@ const PhotoFrame = ({
const handleRangeSelect = (index: number) => () => {
if (rangeStart !== index) {
const checked = !!selected[filteredData[index].id];
const direction =
(index - rangeStart) / Math.abs(index - rangeStart);
let checked = true;
for (let i = rangeStart; i !== index; i += direction) {
checked = checked && !!selected[filteredData[i].id];
}
for (let i = rangeStart; i !== index; i += direction) {
handleSelect(filteredData[i].id)(!checked);
}