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] Autosize not resizing columns properly when rows are fetched asynchronously #14754

Open
Astro-Virens opened this issue Sep 27, 2024 · 4 comments
Labels
component: data grid This is the name of the generic UI component, not the React module! feature: Column resize regression A bug, but worse

Comments

@Astro-Virens
Copy link

Astro-Virens commented Sep 27, 2024

Steps to reproduce

Link to live example: https://codesandbox.io/p/sandbox/elastic-poitras-zlvs3v

Steps:

  1. Datagrid has the autoSizeOnMount property set to true, autosizeOptions contains expand: true
  2. Data is fetched

Current behavior

Columns do not fit the datagrid and horizontal scrollbar is visible when data is fetched asynchronously.
Problem seems to happen only when there's a certain number of rows. In the example, it's 10. Under 10, the autosize feature works well.

Expected behavior

All columns should fit inside the datagrid without horizontal scrollbar showing.

Context

This is especially annoying when the last column is aligned to the right, hiding important information. The user should be able to view the column without having to scroll.

Your environment

npx @mui/envinfo
System:
    OS: Windows 10 10.0.19044
  Binaries:
    Node: 21.7.1 - C:\Program Files\nodejs\node.EXE
    npm: 10.5.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: Not Found
  Browsers:
    Chrome: 128.0.6613.138
  npmPackages:
    @emotion/react: 11.13.0 => 11.13.0
    @emotion/styled: 11.13.0 => 11.13.0
    @mui/core-downloads-tracker:  6.1.0
    @mui/icons-material: 6.1 => 6.1.0
    @mui/material: 6.1 => 6.1.0
    @mui/private-theming:  6.1.0
    @mui/styled-engine:  6.1.0
    @mui/system: 6.1 => 6.1.0
    @mui/types:  7.2.16
    @mui/utils: 6.1 => 6.1.0
    @mui/x-charts: 7.17.0 => 7.17.0
    @mui/x-charts-vendor:  7.16.0
    @mui/x-data-grid: 7.17.0 => 7.17.0
    @mui/x-date-pickers: 7.17.0 => 7.17.0
    @mui/x-internals:  7.17.0
    @types/react: 18.3.3 => 18.3.3
    react: 18.3.1 => 18.3.1
    react-dom: 18.3.1 => 18.3.1
    typescript: 5.4.5 => 5.4.5

Search keywords: DataGrid Autosize

@Astro-Virens Astro-Virens added bug 🐛 Something doesn't work status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Sep 27, 2024
@github-actions github-actions bot added the component: data grid This is the name of the generic UI component, not the React module! label Sep 27, 2024
@michelengelen
Copy link
Member

Thanks for reporting this @Astro-Virens ... it looks like autosizing is broken atm. It is reproducible in the docs as well: Autosizing

I'll add this to the board.

@michelengelen michelengelen changed the title Autosize not resizing columns properly when rows are fetched asynchronously [data grid] Autosize not resizing columns properly when rows are fetched asynchronously Sep 30, 2024
@michelengelen
Copy link
Member

It's actually also a regression, as this was working in v6.

@michelengelen michelengelen added regression A bug, but worse feature: Column resize and removed bug 🐛 Something doesn't work status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Sep 30, 2024
@github-project-automation github-project-automation bot moved this to 🆕 Needs refinement in MUI X Data Grid Sep 30, 2024
@michelengelen michelengelen moved this from 🆕 Needs refinement to 🔖 Ready in MUI X Data Grid Sep 30, 2024
@k-rajat19
Copy link
Contributor

@Astro-Virens have you tried the approach used in this doc section, I think it will resolve the issue?

@Astro-Virens
Copy link
Author

@Astro-Virens have you tried the approach used in this doc section, I think it will resolve the issue?

Thank you for your comment! While it does work, @michelengelen is still correct in saying it was working correctly in v6. Here's the same live example in the issue description, but using DataGrid Pro v6.18 : https://codesandbox.io/p/sandbox/great-shaw-q6qcmx?workspaceId=75e68ec4-eb1d-43d2-b477-1f75b2deccbd

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: Column resize regression A bug, but worse
Projects
Status: 🔖 Ready
Development

No branches or pull requests

3 participants