react-data-grid icon indicating copy to clipboard operation
react-data-grid copied to clipboard

When clicking on the table header, onSelectedCellChange is called with row as undefined

Open Bartmr opened this issue 1 year ago • 1 comments

Describe the bug

When clicking on the table header that is not sortable, onSelectedCellChange is called with row set as undefined

To Reproduce

  1. Click on a table header cell that is not sortable
  2. log the arguments coming in onSelectedCellChange

Link to code example:

Screenshot from 2024-08-21 11-29-44

const columns: Column<Accountant>[] = [
    {
      key: "name",
      name: "Name",
      resizable: true,
      renderCell: (args) => {
        return args.row.name;
      },
    },
    {
      key: "email",
      name: "Email",
      resizable: true,

      renderCell: (args) => {
        return args.row.email;
      },
    },
  ];

return <ReactDataGrid
      className={`rdg-light`}
      rows={props.accountants}
      columns={columns}
      rowKeyGetter={(r) => r.id}
      onSelectedCellChange={(args) => {
        props.onAccountantSelect(args.row.id);
      }}
    />

Expected behavior

Either:

  • don't call onSelectedCellChange when a table header is selected
  • type row argument in onSelectedCellChange as possibly undefined

Environment

  • react-data-grid version: 7.0.0-beta.46
  • react/react-dom version: 18

Additional context

Bartmr avatar Aug 21 '24 10:08 Bartmr

Can you create a reproducible example?

amanmahajan7 avatar Sep 06 '24 18:09 amanmahajan7

Closing due to lack of response.

amanmahajan7 avatar Nov 12 '24 02:11 amanmahajan7