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

[data grid] Problems with copy/paste and the autocomplete dropdown #13461

Closed
mahammahmood opened this issue Jun 12, 2024 · 4 comments
Closed
Labels
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 status: waiting for author Issue with insufficient information support: commercial Support request from paid users support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/

Comments

@mahammahmood
Copy link

mahammahmood commented Jun 12, 2024

The problem in depth

I want the dropdown to remain open while I'm selecting checkboxes when editing a cell, but it closes after a single selection. Also, when I copy a cell and paste it into another cell, it removes the existing data and doesn't paste properly.

Screenshot 2024-06-12 121444

In the screenshot below, when I copy 'Ross Pearson' and paste it into the second row, it clears the data instead of pasting correctly.

Screenshot 2024-06-12 121545
Screenshot 2024-06-12 121711

Here is a live demo of my problem.
DEMO

Your environment

`npx @mui/envinfo`
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: Data, Grid, Premium, Copy, paste, checkbox, dropdown, select, multiple
Order ID: 91010

@mahammahmood mahammahmood added status: waiting for maintainer These issues haven't been looked at yet by a maintainer support: commercial Support request from paid users labels Jun 12, 2024
@michelengelen michelengelen added 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 support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/ labels Jun 12, 2024
@michelengelen michelengelen changed the title The copy/paste functionality in the data grid is not working, and the autocomplete dropdown does not stay open while selecting multiple checkboxes. [data grid] Problems with copy/paste and the autocomplete dropdown Jun 12, 2024
@michelengelen
Copy link
Member

Hey @mahammahmood,

No worries, these aren't bugs – just some areas where we can optimize your code!

Here's the breakdown:

  • Rerenders in CustomEditComponent: You're calling setLocationTaskAssign on every selection in your CustomEditComponent. This triggers a full rerender because it updates the state. To avoid unnecessary rerenders, you should explore memoizing the component or extracting it.

  • Parsing Pasted Values: When you copy complex values like arrays, the clipboard converts them to comma-separated strings. To handle this, we can add a valueSetter function that parses the pasted value before setting it.

These are simple fixes to keep your code running smoothly!

To get you started here is a very simple valueSetter you can use:

valueSetter: (value, row) => {
  console.log(value);
  let newValue = value;
  if (typeof value === 'string') {
    newValue = value.split(',');
  }
  return { ...row, radCenter: newValue };
},

If you need further help consider joining the community on our official discord server.

@michelengelen michelengelen added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jun 12, 2024
@mahammahmood
Copy link
Author

mahammahmood commented Jun 14, 2024 via email

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Jun 14, 2024
@michelengelen
Copy link
Member

@mahammahmood since setLocationTaskAssign will update the state and rerender the component in its entirety there is no way to do what you want.

What do you intend to do with the array? Maybe there is another way around this with the selection state from the grid.

@michelengelen michelengelen added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jun 14, 2024
Copy link

The issue has been inactive for 7 days and has been automatically closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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 status: waiting for author Issue with insufficient information support: commercial Support request from paid users support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/
Projects
None yet
Development

No branches or pull requests

2 participants