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] Fix fluid columns width when available viewportWidth < 0 #1816

Merged

Conversation

DanailH
Copy link
Member

@DanailH DanailH commented Jun 2, 2021

Fixes #1582

Reproduction: https://codesandbox.io/s/material-demo-forked-y2xj0 (when the grid loads start resizing the window to make it small to a point where the last column dissapears)

The problem was that when resizing and space was not enough the fluid columns did not default to the base width of 100px.

Screen.Recording.2021-06-03.at.16.25.05.mov

@DanailH DanailH added the bug 🐛 Something doesn't work label Jun 2, 2021
@DanailH DanailH self-assigned this Jun 2, 2021
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

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

Do we have a reproduction, e.g. there is almost no information on the linked issue. What's the issue?

@DanailH
Copy link
Member Author

DanailH commented Jun 3, 2021

Do we have a reproduction, e.g. there is almost no information on the linked issue. What's the issue?

I'll add a reproduction but the issue is that if you have only one fluid column (as a base case) and you start resing the grid, there is a point where there is no space for the fluid column to be displayed and the grid doesn't allow scrolling so you cant see the last X columns.

PS: @oliviertassinari I added reproduction

@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 3, 2021

@DanailH Great thanks for the reproduction 🙏! We can probably rely on a visual test case here.

It seems to be exactly this pain #1561 (comment). In the realm of AG Grid, this would be expected behavior, and they would tell us: add a minWidth property. I personally feel that if we reproduce the flexbox model of CSS with flex, then a very small column width is normal.

@DanailH
Copy link
Member Author

DanailH commented Jun 4, 2021

@oliviertassinari Visual test can be tricky in this situation as this only happens when you load the grid and then resize the window so that there isn't enough space for all the columns that already have fixed width. If you load the grid in a small space/window initially the regression doesn't happen.

@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 4, 2021

Visual test can be tricky in this situation

@DanailH I'm completely lost. I don't understand where the problem is, why visual regression isn't possible, nor what this PR is changing. See the following:

HEAD: The last column is not visible, looks alright ✅, flex: 1 means it should shrink.

Capture d’écran 2021-06-04 à 13 40 11

https://codesandbox.io/s/material-demo-forked-y2xj0?file=/demo.js:0-587

This PR: Same behavior as on HEAD

Capture d’écran 2021-06-04 à 13 41 10

https://codesandbox.io/s/material-demo-forked-y8m1q?file=/package.json

@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 4, 2021

I mean, see how CSS behaves: flex: 1:

Capture d’écran 2021-06-04 à 13 46 39

And with the same configuration of the columns: https://codepen.io/oliviertassinari/pen/XWMExoz

Capture d’écran 2021-06-04 à 13 48 21

I wouldn't expect width: 100px here for the age column. I think that it only makes sense if we add minWidth: 100px.

@m4theushw
Copy link
Member

@oliviertassinari This PR is fixing the negative widths when there's no available space. A visual test case would not check that but an unit test can.

I think that it only makes sense if we add minWidth: 100px.

So default it to zero?

@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 4, 2021

@m4theushw I think that it should use the default minWidth value when there is not enough space, not the width value because flex overrides width.

@DanailH
Copy link
Member Author

DanailH commented Jun 7, 2021

@m4theushw I think that it should use the default minWidth value when there is not enough space, not the width value because flex overrides width.

@oliviertassinari the thing is that there is no minWidth on the ColDef, I can add one but that is a different PR. Regarding the flex it's just sugar on the ColDef that gets converted to pixels.

@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 7, 2021

@DanailH Ok, so we can close this PR, close #1582, and open a new standalone issue for #1561 (comment) (solving with a new min-width option)?

The reasoning being:

  1. the current logic is correct, it's how CSS work, what we aim to reproduce to avoid developers to learn yet another layout behavior
  2. the changes here make the behavior inconsistent:
    not working

@DanailH
Copy link
Member Author

DanailH commented Jun 7, 2021

@oliviertassinari Done, here is the ticket #1850. We can discuss it today during the sprint planning and bring it in.

@oliviertassinari
Copy link
Member

By close, I meant close, not merge, the behavior is now inconsistent. But it's fine, we can revert in #1850. Thanks for the new issue.

@DanailH
Copy link
Member Author

DanailH commented Jun 9, 2021

By close, I meant close, not merge, the behavior is now inconsistent. But it's fine, we can revert in #1850. Thanks for the new issue.

Sorry I misunderstood. I'll change that once the other ticket is picked up.

ZeeshanTamboli added a commit to ZeeshanTamboli/material-ui-x that referenced this pull request Jun 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DataGrid] Fix width calc for fluid column on resize
4 participants