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] Autosizing does not work if there are less than 4 rows #16311

Open
kennyhei opened this issue Jan 23, 2025 · 1 comment
Open

[data grid] Autosizing does not work if there are less than 4 rows #16311

kennyhei opened this issue Jan 23, 2025 · 1 comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Column resize

Comments

@kennyhei
Copy link

kennyhei commented Jan 23, 2025

Steps to reproduce

Steps:

  1. Open this link to live example with 3 rows: https://stackblitz.com/edit/react-axt64587?file=Demo.tsx
  2. Click "Autosize columns" with "Include headers" checked
  3. Columns are NOT autosized based on header widths only, instead it expands columns so that cell contents are fully visible as well
  4. Now when you toggle off all checkbox options and click "Autosize columns" again, columns won't shrink anymore. Cell content is always fully visible.

Interesting thing here is that if there are 4 rows or more, then toggling options on/off and clicking autosize works perfectly. I froze the stackblitz project but you can test this as well using the demo example in the docs.

Docs: https://mui.com/x/react-data-grid/column-dimensions/#autosizing
In the Autosizing demo example, click "Edit in Stackblitz" or "Edit in Codesandbox".

If it's of any help, same issue happens with latest v6 version as well.

Current behavior

With 3 rows or less, if includeHeaders is set to true while all the other options are false, autosizing still behaves like includeOutliers is true. Then when you set includeHeaders back to false and autosize, cell content does not shrink.

Expected behavior

With 3 rows or less, if includeHeaders is set to true while all the other options are false, autosizing should only take header widths in the calculation. Then when you set it back to false, columns should shrink back to original size.

Context

No response

Your environment

Tried this in docs demo.

Search keywords: autosizing, datagrid

@kennyhei kennyhei added bug 🐛 Something doesn't work status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 23, 2025
@github-actions github-actions bot added the component: data grid This is the name of the generic UI component, not the React module! label Jan 23, 2025
@kennyhei kennyhei changed the title MUI DataGrid - Autosizing does not work if there are less than 4 rows MUI DataGrid - Autosizing docs demo does not work if there are less than 4 rows Jan 23, 2025
@kennyhei kennyhei changed the title MUI DataGrid - Autosizing docs demo does not work if there are less than 4 rows MUI DataGrid - Autosizing does not work if there are less than 4 rows Jan 23, 2025
@michelengelen
Copy link
Member

Hey @kennyhei and thanks for raising this.
I can confirm that the behavior is inconsistent between the described cases where it should be.

I'll add this to the board.

@michelengelen michelengelen added feature: Column resize and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 23, 2025
@michelengelen michelengelen changed the title MUI DataGrid - Autosizing does not work if there are less than 4 rows [data grid] Autosizing does not work if there are less than 4 rows Jan 23, 2025
@github-project-automation github-project-automation bot moved this to 🆕 Needs refinement in MUI X Data Grid Jan 23, 2025
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: Column resize
Projects
Status: 🆕 Needs refinement
Development

No branches or pull requests

2 participants