mui-x icon indicating copy to clipboard operation
mui-x copied to clipboard

[data grid] Change clipboard copy behaviour/precedence?

Open mike-paretos opened this issue 1 year ago • 2 comments

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 avatar Apr 26 '24 09:04 mike-paretos

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.

mike-paretos avatar Apr 26 '24 12:04 mike-paretos

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 ?

michelengelen avatar Apr 26 '24 13:04 michelengelen