Skip to content

[data grid] Cell event handlers props have null|undefined API reference #16866

Open
@joelbalcaen

Description

@joelbalcaen

Steps to reproduce

Steps:

  1. Open this link to live example: https://stackblitz.com/edit/react-wphxoc24?file=Demo.tsx
  2. Open the developer tools console
  3. Focus on a cell
  4. Hit any keyboard key and/or click on a cell
  5. The api references passed to the onCellKeyDown, onCellClick handlers are null or undefined

Current behavior

The Grid API references in the params and details arguments of the onCellKeyDown and onCellClick event handler are undefined or null.

Expected behavior

I expect the grid cell params argument to contain a reference to the Grid API as described here https://mui.com/x/api/data-grid/grid-cell-params/

Context

I am trying to apply a custom cell keydown event handler to all Datagrid in our project using the theme. My use case requires the use of the Grid API. I'm not defining the event handler inside of a React component so I don't have access to the hooks which return a reference to the Grid API

Your environment

npx @mui/envinfo
  System:
    OS: macOS 12.7.3
  Binaries:
    Node: 21.7.1 - /opt/homebrew/bin/node
    npm: 10.5.0 - /opt/homebrew/bin/npm
    pnpm: Not Found
  Browsers:
    Chrome: 133.0.6943.142
    Edge: Not Found
    Safari: 15.6.1

Search keywords: cell event handler api null undefined

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛Something doesn't workcomponent: data gridThis is the name of the generic UI component, not the React module!

    Projects

    Status

    🆕 Needs refinement

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions