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] All grouped rows collapses when rows updating (by state, not by updateRows) #13064

Open
iOrcohen opened this issue May 9, 2024 · 6 comments
Labels
component: data grid This is the name of the generic UI component, not the React module! feature: Row grouping Related to the data grid Row grouping feature support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/

Comments

@iOrcohen
Copy link

iOrcohen commented May 9, 2024

Steps to reproduce

Link to live example: code sandbox

Steps:

  1. Expand one or more of the groups.
  2. Click on one of the buttons - update row, update rows, delete row or add row.
  3. All the groups collapses.

Current behavior

All groups collapses after the rows state changed.

Expected behavior

Groups expansion won't be effected by the rows change.

Context

We update the table rows with fresh data every one minute in our application (It's include coins prices data which require often refresh).
After every refresh all the groups collapses automatically, which make unpleasant user experience.

Your environment

npx @mui/envinfo
  System:
    OS: macOS 14.4.1
  Binaries:
    Node: 18.16.0 - /usr/local/bin/node
    npm: 9.5.1 - /usr/local/bin/npm
    pnpm: Not Found
  Browsers:
    Chrome: 124.0.6367.119
    Edge: Not Found
    Safari: 17.4.1
  npmPackages:
    @emotion/react: ^11.11.4 => 11.11.4 
    @emotion/styled: ^11.11.0 => 11.11.0 
    @mui/base:  5.0.0-beta.28 
    @mui/core-downloads-tracker:  5.15.14 
    @mui/lab: ^5.0.0-alpha.127 => 5.0.0-alpha.157 
    @mui/material: ^5.15.14 => 5.15.14 
    @mui/private-theming:  5.15.14 
    @mui/styled-engine:  5.15.14 
    @mui/system:  5.15.14 
    @mui/types:  7.2.14 
    @mui/utils:  5.15.14 
    @mui/x-data-grid:  6.19.11 
    @mui/x-data-grid-premium: ^6.19.11 => 6.19.11 
    @mui/x-data-grid-pro:  6.19.11 
    @mui/x-date-pickers: ^6.10.2 => 6.18.5 
    @mui/x-date-pickers-pro: ^6.18.0 => 6.18.5 
    @mui/x-license-pro:  6.10.2 
    @types/react:  18.2.45 
    react: ^18.2.0 => 18.2.0 
    react-dom: ^18.2.0 => 18.2.0 
    typescript: ^4.9.5 => 4.9.5 

Search keywords: expansion, grouping
Order ID: 66471 + 90144

@iOrcohen iOrcohen added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 9, 2024
@zannager zannager 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 May 9, 2024
@michelengelen michelengelen changed the title MUI Datagrid V6 - All grouped rows collapses when rows updating (by state, not by updateRows) [data grid] All grouped rows collapses when rows updating (by state, not by updateRows) May 13, 2024
@michelengelen
Copy link
Member

Hey @iOrcohen ... thanks for opening this ticket.
The behavior you are describing is actually to be expected.
Since re-rendering the complete data grid on every state change it will re-render with the initialState and the collapsed rows.
This can be prevented when using the updateRows method from the apiRef or, if this is not an option, you can always create a custom state and function for isGroupExpandedByDefault. This is from the group expansion part of the docs.

@cherniavskii is there any plan of including the row-expansion state in the grid state?

@michelengelen michelengelen added status: waiting for author Issue with insufficient information feature: Row grouping Related to the data grid Row grouping feature and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 13, 2024
@iOrcohen
Copy link
Author

@michelengelen Thanks for your comment!
We will try solve it by using the updateRows function, but since the common usage of the rows change is by changing the state, I think the row expansion should be part of the grid state, and remain the same from render to render as same as filtering, grouping and all the others.

If the plan is to the add the row-expansion to the grid state, let me know and I might contribute it myself :)

Thanks again.

@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 May 13, 2024
@michelengelen michelengelen removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 14, 2024
@michelengelen
Copy link
Member

I did add this to the board. 👍🏼

@iOrcohen
Copy link
Author

@michelengelen I'm sorry but just for clarification, does it mean this feature is in the roadmap?
Is there any estimation if so?
I'm trying to think if I should manage the updateRows solution in the meanwhile.

Thanks again!

@michelengelen
Copy link
Member

michelengelen commented May 15, 2024

@michelengelen I'm sorry but just for clarification, does it mean this feature is in the roadmap?

Is there any estimation if so?

I'm trying to think if I should manage the updateRows solution in the meanwhile.

Thanks again!

It is currently not planned as part of the roadmap. Adding it to the board is the first step of starting a discussion about it and eventually coming up with a fast solution.

@cherniavskii
Copy link
Member

Related discussion: #7771

We might reconsider the default behavior for the next major since the current behavior is clearly confusing to many users.

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: Row grouping Related to the data grid Row grouping feature 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

4 participants