mui / mui-x

MUI X: Build complex and data-rich applications using a growing list of advanced React components, like the Data Grid, Date and Time Pickers, Charts, and more!
https://mui.com/x/
4.52k stars 1.31k forks source link

[Data grid] Possibility of having a confirmation dialog in actions within the menu #8593

Closed Nic-S closed 1 year ago

Nic-S commented 1 year ago

Duplicates

Latest version

Summary 💡

It is common practice to have a confirmation dialogue for certain actions.

In order to compose better and improve performance, avoiding the rerendering of the component where the grid is, I would like the possibility to create the component with both actio and dialog.

Problem: If the action is in the menu, the solution described above is not possible because when the action is clicked in the menu, the popup is closed and consequently the dialogue is also unmounted.

Possible solutions:

  1. Expose the callback to command the closing of the popup from the menu item so that the closing state can be commanded if necessary.
  2. Having an action that opens a confirmation dialog on click.

Examples 🌈

https://codesandbox.io/s/eager-golick-2kgkb0?file=/demo.tsx

Motivation 🔦

No response

Order ID 💳 (optional)

No response

m4theushw commented 1 year ago

We don't plan to add an API method to control the state of the actions menu. The state of the menu is controlled by the cell component. In API methods we can only control the global state. As alternative you need to render the dialog outside the grid.