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] column resize issue with tree data #15601

Open
toddsmith-adsk opened this issue Nov 26, 2024 · 3 comments
Open

[data grid] column resize issue with tree data #15601

toddsmith-adsk opened this issue Nov 26, 2024 · 3 comments
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Tree data Related to the data grid Tree data feature support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/

Comments

@toddsmith-adsk
Copy link

toddsmith-adsk commented Nov 26, 2024

Steps to reproduce

Steps:

  1. Open this link to live example: (example)
  2. Expand all items in the Group tree column

Current behavior

Columns are not wide enough

image

Example from my own app

image

paused in debugger after call to root.classList.add(gridClasses.autosizing);

image

image

Expected behavior

Wider columns that fit all the data

Context

No response

Your environment

npx @mui/envinfo
System:
    OS: Windows 10 10.0.19045
  Binaries:
    Node: 18.19.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.2.3 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.7.1 - C:\Program Files\nodejs\pnpm.CMD
  Browsers:
    Chrome: Not Found
    Edge: Chromium (127.0.2651.105)
  npmPackages:
    @emotion/react: ^11.13.3 => 11.13.5
    @emotion/styled: ^11.13.0 => 11.13.5
    @mui/base:  5.0.0-beta.62
    @mui/core-downloads-tracker:  6.1.8
    @mui/icons-material: ^6.1.7 => 6.1.8
    @mui/lab: ^6.0.0-beta.15 => 6.0.0-beta.16
    @mui/material: ^6.1.7 => 6.1.8
    @mui/private-theming:  6.1.8
    @mui/styled-engine:  6.1.8
    @mui/system:  6.1.8
    @mui/types:  7.2.19
    @mui/utils:  6.1.8
    @mui/x-data-grid: ^7.22.2 => 7.22.3
    @mui/x-data-grid-premium: ^7.22.2 => 7.22.3
    @mui/x-data-grid-pro:  7.22.3
    @mui/x-internals:  7.21.0
    @mui/x-license:  7.21.0
    @types/react: ^18.3.12 => 18.3.12
    react: ^18.3.1 => 18.3.1
    react-dom: ^18.3.1 => 18.3.1
    typescript: ^5.6.3 => 5.7.2

Search keywords: column resize tree data
Order ID: 86253

@toddsmith-adsk toddsmith-adsk added bug 🐛 Something doesn't work status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 26, 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 Nov 26, 2024
@michelengelen michelengelen changed the title column resize issue with tree data [data grid] column resize issue with tree data Nov 26, 2024
@michelengelen
Copy link
Member

Ok, I just tested this and it indeed is a bit unexpected that it's not properly respecting the expanded cells. The reason is actually a race condition. The autosizing happens before the new rows are showing.

As a workaround you can wrap the autosizing in a timeout:

const handleRowExpansionChange: GridEventListener<'rowExpansionChange'> = (params: any) => {
  console.log('rowExpansionChange: ', params);

  setTimeout(
    () =>
      apiRef.current.autosizeColumns({
        columns: ['__tree_data_group__'],
        includeOutliers: true,
      }),
    0,
  );
};

I'll add this to the board so that the team can pick it up and properly handle it.
Thanks for opening it! 👍🏼

@michelengelen michelengelen added feature: Tree data Related to the data grid Tree data feature and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 26, 2024
@github-project-automation github-project-automation bot moved this to 🆕 Needs refinement in MUI X Data Grid Nov 26, 2024
@toddsmith-adsk
Copy link
Author

Adding the timeout event with a 1s delay did not resolve the issue.

mui-datagrid-expando

@michelengelen
Copy link
Member

Adding the timeout event with a 1s delay did not resolve the issue.

Seems like the leaf row is not calculated correctly ... might be a different bug though.

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: Tree data Related to the data grid Tree data feature support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/
Projects
Status: 🆕 Needs refinement
Development

No branches or pull requests

2 participants