kendo-react icon indicating copy to clipboard operation
kendo-react copied to clipboard

[Bug][Grid] Checkbox Selection and Virtualization incorrect row selection

Open WissamProgress opened this issue 1 year ago • 1 comments

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

  1. Add checkbox selection and virtualization for the Grid https://stackblitz.com/edit/react-nigr7r?file=app%2Fapp.tsx
  2. Scroll down
  3. 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

WissamProgress avatar Jul 08 '24 15:07 WissamProgress

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

kdikov82 avatar Aug 21 '24 16:08 kdikov82

available fix in v11.0.0-develop.17.

ivanchev avatar May 20 '25 10:05 ivanchev