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] Performance: DOM changes #12013

Merged
merged 21 commits into from
Feb 22, 2024
Merged

[data grid] Performance: DOM changes #12013

merged 21 commits into from
Feb 22, 2024

Conversation

romgrk
Copy link
Contributor

@romgrk romgrk commented Feb 9, 2024

Closes #10570

Changes:

  • Remove the .cell > .cellContent DOM node. Fewer DOM nodes means a faster rendering.
  • Remove some styles to remove complexity & improve performance.
  • Rework autosizing to make it work with the new layout and make it more robust.

Before: https://deploy-preview-12012--material-ui-x.netlify.app/x/react-data-grid/#pro-plan
After: https://deploy-preview-12013--material-ui-x.netlify.app/x/react-data-grid/#pro-plan

Further help with #11866

@romgrk romgrk added the component: data grid This is the name of the generic UI component, not the React module! label Feb 9, 2024
@mui-bot
Copy link

mui-bot commented Feb 9, 2024

@oliviertassinari oliviertassinari changed the title [DataGrid] Performance: DOM changes [data grid] Performance: DOM changes Feb 10, 2024
@romgrk romgrk marked this pull request as ready for review February 10, 2024 20:29
@romgrk
Copy link
Contributor Author

romgrk commented Feb 10, 2024

There are a few argos changes, I feel like the remaining ones are acceptable. The one that's really apparent is that sibling cells of dynamic height cells have their content top-aligned rather than centered, which isn't necessarily wrong, more like different.

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.

Linked #3587 to make it easier to follow the history.

It would have probably been great to add a visual regression test in #3446. It seems to me that we are good on this PR, but it would have helped us move with more confidence.
Same thoughts with #3955, it's not clear that we have tested. Maybe it's a detail.

Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
Signed-off-by: Rom Grk <romgrk@users.noreply.github.com>
docs/pages/x/api/data-grid/data-grid-pro.json Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

I don't get this change in Argos: https://app.argos-ci.com/mui/mui-x/builds/17744/76165287
I cannot reproduce this in the preview deployment: https://deploy-preview-12013--material-ui-x.netlify.app/x/react-data-grid/api-object/#inside-the-data-grid

Any ideas? Could this be related to OS font rendering?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I figured it's a text underline rendering issue caused by the change in display value, I would think it's an upstream chromium issue.

Copy link
Member

Choose a reason for hiding this comment

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

@romgrk I cannot reproduce it on MacOS (Chromium: 121.0.6167.139).
Can you reproduce it on Linux?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, the underline is cropped cleanly:
image

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I couldn't find a way to preserve that while satisfying the other constraints. CSS doesn't do vertical centering well unless it's in flex/grid mode. Vertical padding would mess up the space available, and the trick for text cells was to set the line-height to height (copied from ag-grid).

Copy link
Member

Choose a reason for hiding this comment

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

the trick for text cells was to set the line-height to height

In the linked demos, the cells impacted are text cells.
Should we add display: 'flex' then?
Also, could you mention this change in the migration guide?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's the one case I couldn't make work, but as I mention above, I don't feel it's necessarily wrong. Trying to fix it would introduce too much magic imho, so I'd leave that change as it is.

I've added a note to the guide.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And for the demo in particular, I also wouldn't add display: 'flex' because I'd rather demo the default behavior.

Copy link
Member

Choose a reason for hiding this comment

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

Alright, thanks for the clarification.

@romgrk romgrk merged commit d9ac050 into mui:next Feb 22, 2024
17 checks passed
@romgrk romgrk deleted the perf-dom-changes branch February 22, 2024 09:39
thomasmoon pushed a commit to thomasmoon/mui-x that referenced this pull request Sep 9, 2024
Signed-off-by: Rom Grk <romgrk@users.noreply.github.com>
Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
Co-authored-by: Andrew Cherniavskyi <andrew@mui.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change component: data grid This is the name of the generic UI component, not the React module! performance v7.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[datagrid] Autosize Columns - Headers being cut off
4 participants