Skip to content

[docs] Add recipe for triggering clipboard copy from a button#22967

Merged
michelengelen merged 9 commits into
mui:masterfrom
michelengelen:recipe/datagrid/18897
Jun 29, 2026
Merged

[docs] Add recipe for triggering clipboard copy from a button#22967
michelengelen merged 9 commits into
mui:masterfrom
michelengelen:recipe/datagrid/18897

Conversation

@michelengelen

Copy link
Copy Markdown
Member

Adds a demo showing how to reproduce the Ctrl+C copy priority logic using only public APIs (getSelectedCellsAsArray, getCellSelectionModel, getDataAsCsv, gridFocusCellSelector), so users can trigger a copy from a button, context menu, or touch interface without relying on the keyboard shortcut.

Resolves #18897

@michelengelen michelengelen self-assigned this Jun 26, 2026
@michelengelen michelengelen added docs Improvements or additions to the documentation. scope: data grid Changes related to the data grid. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. recipe labels Jun 26, 2026
Signed-off-by: michel <[email protected]>
@code-infra-dashboard

code-infra-dashboard Bot commented Jun 26, 2026

Copy link
Copy Markdown

Deploy preview

Bundle size

Bundle Parsed size Gzip size
@mui/x-data-grid 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-pro 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-premium 0B(0.00%) 0B(0.00%)
@mui/x-charts 0B(0.00%) 0B(0.00%)
@mui/x-charts-pro 0B(0.00%) 0B(0.00%)
@mui/x-charts-premium 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers-pro 0B(0.00%) 0B(0.00%)
@mui/x-tree-view 0B(0.00%) 0B(0.00%)
@mui/x-tree-view-pro 0B(0.00%) 0B(0.00%)
@mui/x-license 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@michelengelen michelengelen changed the title [docs][data-grid] Add recipe for triggering clipboard copy from a button [docs] Add recipe for triggering clipboard copy from a button Jun 26, 2026
return sortedRowIds
.map((rowId) =>
Object.keys(cellSelectionModel[rowId])
.filter((field) => cellSelectionModel[rowId][field])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty cells should be kept as '', to prevent shifting of the values on paste

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adressed in 42da259

Comment thread docs/data/data-grid/clipboard/clipboard.md Outdated
@michelengelen
michelengelen enabled auto-merge (squash) June 29, 2026 08:32
@michelengelen
michelengelen merged commit 7a86d3d into mui:master Jun 29, 2026
21 checks passed
@michelengelen
michelengelen deleted the recipe/datagrid/18897 branch June 29, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to the documentation. recipe scope: data grid Changes related to the data grid. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[data grid] How to copy cell selection without keyboard shortcuts?

2 participants