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/
3.82k stars 1.14k forks source link

[data grid] Change clipboard copy behaviour/precedence? #12913

Open mike-paretos opened 3 weeks ago

mike-paretos commented 3 weeks ago

The problem in depth

We have a table with a checkbox selection with the selection of the row on click disabled. (basically https://mui.com/x/react-data-grid/row-selection/#disable-row-selection-on-click)

Let's assume a user has selected a couple of rows. Then, a user selects a cell and wants to copy it.

The current behavior it always copies the selected rows (with the checkboxes), but not the selected cell.

Question Is there a possibility to prevent that behavior and copy selected cell content instead of the content of selected rows?

Your environment

`npx @mui/envinfo` ``` "@mui/icons-material": "^5.14.0", "@mui/lab": "^5.0.0-alpha.136", "@mui/material": "^5.14.0", "@mui/utils": "^5.15.14", "@mui/x-data-grid-premium": "^6.18.7", "@mui/x-date-pickers": "^7.0.0", "@mui/x-date-pickers-pro": "^7.0.0", "@mui/x-license-pro": "^6.10.2", ```

Search keywords: onClipboardCopy, Clipboard Copy and Row Selection Order ID: 82474

mike-paretos commented 3 weeks ago

Basically, we need the possibility to change the priorities that are described here (https://mui.com/x/react-data-grid/clipboard/#clipboard-copy), making the 'If there is a single cell selected, the single cell is copied' the top priority.

michelengelen commented 3 weeks ago

Hey @mike-paretos, afaik this is currently not possible. We could introduce a new prop specifically for clipboard copy, like clipboardCopyPrecedence with predefined values ['multiCell', 'row', 'singleCell']

WDYT @cherniavskii ?