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

[DataGridPremium] Fix paste to selected cells #13967

Merged
merged 5 commits into from
Jul 24, 2024

Conversation

romgrk
Copy link
Contributor

@romgrk romgrk commented Jul 24, 2024

Closes #13703

Fix pasting to multiple selected cells. The root cause is that the selection model is an unordered record of the selected cells, but we were Object.entries()'ing it, which didn't produce the same ordering as the visible rows.

Before: https://codesandbox.io/p/devbox/lck95j?file=%2Fsrc%2FDemo.tsx
After: https://codesandbox.io/p/sandbox/mui-mui-x-x-data-grid-forked-2wzpkz?file=%2Fsrc%2Fdemo.tsx

@romgrk romgrk added bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! labels Jul 24, 2024
@romgrk romgrk requested a review from a team July 24, 2024 12:23
@mui-bot
Copy link

mui-bot commented Jul 24, 2024

Deploy preview: https://deploy-preview-13967--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against c286d69

Copy link
Contributor

@KenanYusuf KenanYusuf left a comment

Choose a reason for hiding this comment

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

Tested it and it seems to paste in the original order now.

I observed another issue where if you try to copy a cell after previously pasting, the previously pasted cells get reset:

issue.mp4

@romgrk are you able to reproduce this? Shall I create a separate issue if so?

@romgrk
Copy link
Contributor Author

romgrk commented Jul 24, 2024

That's a bug with the demo code provided by the user, rows is defined inside the component so it resets it when it rerenders.

@romgrk romgrk merged commit 62ba349 into mui:master Jul 24, 2024
17 checks passed
@romgrk romgrk deleted the fix-paste-to-selected-cells branch July 24, 2024 13:43
@cherniavskii cherniavskii added plan: Premium Impact at least one Premium user feature: Clipboard Related to clipboard copy or paste functionalities labels Jul 25, 2024
@cherniavskii cherniavskii changed the title [DataGrid] Fix paste to selected cells [DataGridPremium] Fix paste to selected cells Jul 25, 2024
thomasmoon pushed a commit to thomasmoon/mui-x that referenced this pull request Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Clipboard Related to clipboard copy or paste functionalities plan: Premium Impact at least one Premium user
Projects
None yet
4 participants