Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional context menu handlers #15946

Open
trbagley-gresham opened this issue Dec 19, 2024 · 0 comments
Open

Additional context menu handlers #15946

trbagley-gresham opened this issue Dec 19, 2024 · 0 comments
Labels
component: data grid This is the name of the generic UI component, not the React module! customization: logic Logic customizability enhancement This is not a bug, nor a new feature support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/ waiting for 👍 Waiting for upvotes

Comments

@trbagley-gresham
Copy link

trbagley-gresham commented Dec 19, 2024

Summary

There is currently an onColumnHeaderContextMenu event to capture right clicking on the column header. It would be useful to extend these handlers to include an onRowContextMenu and onCellContextMenu. Whilst a similar outcome can be achieved using the onContextMenu slot prop, extra work is required to extract useful properties such as the column definition.

The solution involves exposing an onRowContextMenu and onCellContextMenu prop directly from the grid to create a consistent API. Both handlers would follow the same interface as their left click counterparts:

export interface GridRowEventLookup {
    /**
     * Fired when the user attempts to open a context menu in from a row.
     */
    rowContextMenu: {
        params: GridRowParams;
        event: React.MouseEvent<HTMLElement>;
    };
}

export interface GridCellEventLookup {
    /**
     * Fired when the user attempts to open a context menu in a cell.
     */
    cellContextMenu: {
        params: GridCellParams<any>;
        event: React.MouseEvent<HTMLElement>;
    };
}

They would then be exposed from the grid like so:

<DataGrid onRowContextMenu={...} onCellContextMenu={...} />

Examples

#14734

Motivation

Listen for context menu events on grid cells with simplified access to cell properties (e.g. colDef, value etc.).

Search keywords: eventhandler contextmenu prop

Order ID: 45466

@trbagley-gresham trbagley-gresham added new feature New feature or request status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Dec 19, 2024
@github-actions github-actions bot added the support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/ label Dec 19, 2024
@cherniavskii cherniavskii added component: data grid This is the name of the generic UI component, not the React module! waiting for 👍 Waiting for upvotes customization: logic Logic customizability enhancement This is not a bug, nor a new feature and removed new feature New feature or request status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! customization: logic Logic customizability enhancement This is not a bug, nor a new feature support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/ waiting for 👍 Waiting for upvotes
Projects
None yet
Development

No branches or pull requests

2 participants