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] onRowSelectionModelChange is called when treeData is enabled and rows changes #15068

Closed
goldst opened this issue Oct 23, 2024 · 4 comments · Fixed by #15184
Closed
Assignees
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/

Comments

@goldst
Copy link

goldst commented Oct 23, 2024

Steps to reproduce

Link to live example: https://codesandbox.io/p/sandbox/hopeful-maxwell-dxvvlw?from-embed=&workspaceId=67e261df-ad7c-4156-98c4-4a0336fb54f4

Steps:

  1. Open the console and click the button above the grid that says "add a row"

Current behavior

Despite the row selection not changing, onRowSelectionModelChange is being called. See the console output.

Expected behavior

onRowSelectionModelChange should not be called when changing rows, unless the row selection changes too. In the example, there should be no console output.

If it is technically impossible not to call onRowSelectionModelChange in this case, it should at least return the same array (not a new one with the same values) so I can easily check whether the row selection model changed.

Context

This worked correctly in v7.18.0. It breaks in v7.19.0 and hasn't been fixed since.

We reset parts of our UI when the row selection changes. For this, we use onRowSelectionModelChange. We cannot compare the row selection array content with the previous content because of performance. There are too many selected rows.

This only happens when treeData is enabled.

Your environment

bunx @mui/envinfo
  System:
    OS: Linux 5.15 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
  Binaries:
    Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.1/bin/npm
    pnpm: 9.6.0 - /mnt/c/Users/lgoldstein/AppData/Roaming/npm/pnpm
  Browsers:
    Chrome: 121.0.6167.85
  npmPackages:
    @emotion/react: ^11.11.4 => 11.11.4 
    @emotion/styled: ^11.11.5 => 11.11.5 
    @mui/base:  5.0.0-beta.42 
    @mui/core-downloads-tracker:  6.1.2 
    @mui/icons-material: ^6.1.2 => 6.1.2 
    @mui/lab: ^6.0.0-beta.10 => 6.0.0-dev.240424162023-9968b4889d 
    @mui/material: ^6.1.2 => 6.1.2 
    @mui/private-theming:  6.1.0 
    @mui/styled-engine:  6.1.0 
    @mui/system:  6.1.0 
    @mui/types:  7.2.15 
    @mui/utils:  6.1.0 
    @mui/x-data-grid:  7.21.0 
    @mui/x-data-grid-premium: ^7.21.0 => 7.21.0 
    @mui/x-data-grid-pro:  7.21.0 
    @mui/x-date-pickers:  7.21.0 
    @mui/x-date-pickers-pro: ^7.21.0 => 7.21.0 
    @mui/x-internals:  7.21.0 
    @mui/x-license: ^7.18.0 => 7.18.0 
    @types/react: ~18.3.11 => 18.3.11 
    react: ^18.3.1 => 18.3.1 
    react-dom: ^18.3.1 => 18.3.1 
    typescript: ^5.6.3 => 5.6.3 

Reproducible in Chrome and Firefox.

Search keywords: onRowSelectionModelChange, treeData, rows, reference changes
Order ID: 95800

@goldst goldst added bug 🐛 Something doesn't work status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Oct 23, 2024
@github-actions github-actions bot added component: data grid This is the name of the generic UI component, not the React module! support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/ labels Oct 23, 2024
@goldst goldst changed the title onRowSelectionModelChange is called when treeData is enabled and rows changes [data grid] onRowSelectionModelChange is called when treeData is enabled and rows changes Oct 23, 2024
@MBilalShafi
Copy link
Member

I'll take a look on this, it seems to be related to #13757 that got shipped in v7.19.0, technically it should also be there in v7.19.0 though.

@MBilalShafi MBilalShafi removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Oct 23, 2024
@MBilalShafi MBilalShafi self-assigned this Oct 23, 2024
@goldst
Copy link
Author

goldst commented Oct 23, 2024

Thank you @MBilalShafi for the quick response. Small correction to my description: in the description, I said that it broke in v7.20.0, but it broke in v7.19.0. I adjusted it.

@MBilalShafi
Copy link
Member

Thanks @goldst for the clarification 👍
That confirms my doubt that it's related to #13757.

Copy link

github-actions bot commented Nov 4, 2024

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

Note

@goldst How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

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! support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants