kendo-react
kendo-react copied to clipboard
[Bug][Grid] Checkbox Selection and Virtualization incorrect row selection
I'm submitting a...
- Bug report
Current behavior
When combining checkbox selection with virtualization, selecting a specific row results in the selection of a different one. The issue is from the event of the onSelectionChange event that returns an invalid row index.
Expected behavior
Correct row selection with virtualization. This is the case with normal selection https://stackblitz.com/edit/react-qe9nwp-rgvydp?file=app%2Fapp.jsx
Minimal reproduction of the problem with instructions
- Add checkbox selection and virtualization for the Grid https://stackblitz.com/edit/react-nigr7r?file=app%2Fapp.tsx
- Scroll down
- Select a row using the checkbox element -> a row from the first page (before scrolling) gets selected
Related to https://github.com/telerik/kendo-react/issues/2288 Ticket ID: 1656732
Temporary workaround:
const onSelectionChange = React.useCallback(
(event: GridSelectionChangeEvent) => {
if (event.syntheticEvent.type == 'change') {
const newState = { ...selectedState };
newState[event.dataItem[DATA_ITEM_KEY]] = newState[
event.dataItem[DATA_ITEM_KEY]
]
? !newState[event.dataItem[DATA_ITEM_KEY]]
: true;
setSelectedState(newState);
} else {
const newSelectedState = getSelectedState({
event,
selectedState: selectedState,
dataItemKey: DATA_ITEM_KEY,
});
setSelectedState(newSelectedState);
}
},
[selectedState]
);
https://stackblitz.com/edit/react-nigr7r-jpcmqd?file=app%2Fapp.tsx,app%2Fshared-gd-products.json
available fix in v11.0.0-develop.17.