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

[DataGrid] Make column autosizing work with dynamic row height #10693

Merged

Conversation

cherniavskii
Copy link
Member

@cherniavskii cherniavskii commented Oct 16, 2023

Exploration of #10669

Demo: https://codesandbox.io/s/vigilant-bouman-57jg8d?file=/src/demo.tsx
It doesn't work great with calling autosizeColumns on resize, but it might be feasible for double-click autosizing.

Preview: https://deploy-preview-10693--material-ui-x.netlify.app/x/react-data-grid/column-dimensions/#autosizing-with-dynamic-row-height

@cherniavskii cherniavskii added the component: data grid This is the name of the generic UI component, not the React module! label Oct 16, 2023
@mui-bot
Copy link

mui-bot commented Oct 16, 2023

@cherniavskii
Copy link
Member Author

@romgrk What do you think?

@romgrk
Copy link
Contributor

romgrk commented Oct 17, 2023

Looks ok, I feel like there's going to be edge-cases that we haven't thought of but if it works let's do it.

@cherniavskii
Copy link
Member Author

@romgrk Yes, I thought we might avoid some edge cases if maxWidth is set on the column.
Initially, my idea was to make maxWidth required for autosizing to work with dynamic row height.
But on second thought, maybe recommending setting maxWidth in the docs would be enough?

Another option would be for the data grid to automatically limit the column width to not exceed the grid width when dynamic row height is being used.

@romgrk
Copy link
Contributor

romgrk commented Oct 17, 2023

Recommending maxWidth seems enough.

I woudn't do the other option but I'm not opposed to it.

@cherniavskii cherniavskii force-pushed the autosizing-with-dynamic-row-height branch from 1fdc8e4 to 3b6d61b Compare October 24, 2023 19:21
@cherniavskii cherniavskii added feature: Row height Related to the data grid Row height features feature: Column resize enhancement This is not a bug, nor a new feature labels Oct 24, 2023
@cherniavskii cherniavskii marked this pull request as ready for review October 25, 2023 12:02
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 29, 2023
@github-actions

This comment was marked as resolved.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 30, 2023
Comment on lines 158 to 161
[`& .${gridClasses.cell} > *`]: {
overflow: 'visible !important',
whiteSpace: 'nowrap',
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We know what to whitespace: nowrap because we assume a certain layout for the cells, but for custom rendered cells this might not work. There is no general solution to that though, let's just wait until someone has that problem.

@cherniavskii cherniavskii merged commit 2eae396 into mui:master Oct 30, 2023
18 checks passed
@cherniavskii cherniavskii deleted the autosizing-with-dynamic-row-height branch October 30, 2023 16:53
alexfauquette pushed a commit to alexfauquette/mui-x that referenced this pull request Nov 6, 2023
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! enhancement This is not a bug, nor a new feature feature: Column resize feature: Row height Related to the data grid Row height features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants