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] Double click column border to autosize grid column width not working. #12733

Closed
mschaefer-gresham opened this issue Apr 10, 2024 · 4 comments
Labels
component: data grid This is the name of the generic UI component, not the React module! feature: Column resize

Comments

@mschaefer-gresham
Copy link

mschaefer-gresham commented Apr 10, 2024

Steps to reproduce

Double clicking a grid column to autosize it does not work most of the time. The below example is a fork from a grid example on the MUI website. With 5 rows the autosizing of 'Last name' does not work. But if you remove all but one column, then autosizing works.

2024-04-10_14-17-08.mp4

https://codesandbox.io/p/sandbox/thirsty-lovelace-cwwsp7?file=%2Fsrc%2FDemo.tsx%3A37%2C77

Current behavior

Double clicking column border to autosize does not work.

Expected behavior

It should work.

Context

Trying to autosize a column based on the width of the data in this column's rows.

Your environment

My example is a forked CodeBox from the MUI website.

Search keywords: autosize column width grid double-click
Order ID: 45466

@mschaefer-gresham mschaefer-gresham added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Apr 10, 2024
@mschaefer-gresham mschaefer-gresham changed the title Double click column border to autosize grid column with not working. Double click column border to autosize grid column width not working. Apr 10, 2024
@michelengelen
Copy link
Member

Hey @mschaefer-gresham
For this to always work you would need to pass autosizeOptions to the grid.

autosizeOptions={{
  includeOutliers: true,
  includeHeaders: true,
}}

I am not 100% sure what kind of algorithm is used when the defaults, includeOutliers: false and includeHeaders: false are used, but this will make sure that the columns are always autosized to fit the content (when there is enough space for it)

@michelengelen michelengelen added component: data grid This is the name of the generic UI component, not the React module! status: waiting for author Issue with insufficient information feature: Column resize and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Apr 10, 2024
@michelengelen
Copy link
Member

@mschaefer-gresham does that fix your use case?

@michelengelen michelengelen changed the title Double click column border to autosize grid column width not working. [data grid] Double click column border to autosize grid column width not working. Apr 10, 2024
@mschaefer-gresham
Copy link
Author

@michelengelen thank you. This appears to solve the issue.

@github-actions github-actions bot removed the status: waiting for author Issue with insufficient information label Apr 10, 2024
Copy link

⚠️ This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

@mschaefer-gresham: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

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
Projects
None yet
Development

No branches or pull requests

2 participants