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 autosizing calculated on old data instead of new data #12940

Open
Frooons opened this issue Apr 29, 2024 · 0 comments
Open
Assignees
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module!

Comments

@Frooons
Copy link

Frooons commented Apr 29, 2024

Steps to reproduce

Link to live example: https://stackblitz.com/edit/react-e7tkn5?file=Demo.tsx

Current behavior

The community version of data grid uses the old data set to set the --DataGrid-rowWidth css variable when using the autosizeColumns functionality, resulting in inconsistencies between the header and data rows.

Row exceeds header length:
image

Header exceeds row length:
image

The pro version does set the --DataGrid-rowWidth based on the new data, as shown in the screenshot below. The pro version above the community version below, both using the same data but different widths:
image

Expected behavior

The community version should also set the --DataGrid-rowWidth based on the new data just like the pro version does.

Context

The live example is a fork of autosizing asynchronously with extended data and the community version added below to the pro version, both use the same logic to retrieve the data and execute the autosizeColumns.

With the browser inspector open, clicking the refresh button I see the style attribute of the MuiDataGrid-root div refreshed immediately for the community version which is too soon. With the pro version the style attribute of the MuiDataGrid-root div is refreshed after the new data is loaded.

Your environment

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

Search keywords: Autosizing

@Frooons Frooons added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Apr 29, 2024
@zannager zannager added the component: data grid This is the name of the generic UI component, not the React module! label Apr 29, 2024
@romgrk romgrk self-assigned this Apr 29, 2024
@romgrk romgrk added bug 🐛 Something doesn't work and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Apr 29, 2024
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!
Projects
None yet
Development

No branches or pull requests

3 participants