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 cell height after changing grid's density #1819

Merged

Conversation

DanailH
Copy link
Member

@DanailH DanailH commented Jun 3, 2021

Fixes #1776

The problem was related to grabbing the height from the state inside GridRowCells component which is memoized. Passing it as a prop solves the issue. I extended the existing density tests to cover that case.

Preview: https://deploy-preview-1819--material-ui-x.netlify.app/components/data-grid/accessibility/#density-selector

@DanailH DanailH added bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! labels Jun 3, 2021
@DanailH DanailH self-assigned this Jun 3, 2021
@@ -105,6 +115,11 @@ describe('<DataGrid /> - Toolbar', () => {
expect(screen.getAllByRole('row')[1]).toHaveInlineStyle({
maxHeight: `${Math.floor(rowHeight * COMPACT_DENSITY_FACTOR)}px`,
});

// @ts-expect-error need to migrate helpers to TypeScript
expect(screen.getAllByRole('cell')[1]).toHaveInlineStyle({
Copy link
Member

Choose a reason for hiding this comment

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

we could just load the maxHeight and do an equal assert to avoid the ts-error

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes but that tests the internal, not the visual part. For me this way the test is more secure. If we change the way the height of the cell is set then if we check the maxHeight the test will stop working, no?

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.

It looks like the bug resonates with #1618 (comment).

Regarding the solution, did we consider to 1. only have a height property on the row, not on the cells? 2. No min-height/max-height, only height?

@DanailH
Copy link
Member Author

DanailH commented Jun 4, 2021

It looks like the bug resonates with #1618 (comment).

Regarding the solution, did we consider to 1. only have a height property on the row, not on the cells? 2. No min-height/max-height, only height?

That was the easiest way to solve the issue. Regarding 2. it will still be the same problem I think as even if we only have height it still needs to come from the state and be based on the row height. Option 1. is more favorable. I will see if the effort of depending only on the row height is too big.

@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 4, 2021

@DanailH Yeah, 1. and 2. are a bit off-topic. I was raising them as they seemed possible opportunities to improve the logic.

@oliviertassinari
Copy link
Member

I have updated #1618 (comment) to keep track of the bugs created by the useGridSelector that doesn't work cross memo functions.

@DanailH DanailH merged commit 868b2a0 into mui:master Jun 7, 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 component: data grid This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DataGrid] Density selector not working
3 participants