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
36 changes: 24 additions & 12 deletions docs/pages/x/api/data-grid/data-grid-premium.json
Original file line number Diff line number Diff line change
Expand Up @@ -752,12 +752,6 @@
"description": "Styles applied the cell if `showColumnVerticalBorder={true}`.",
"isGlobal": false
},
{
"key": "cell--withRenderer",
"className": "MuiDataGridPremium-cell--withRenderer",
"description": "Styles applied to the cell element if the cell has a custom renderer.",
"isGlobal": false
},
{
"key": "cell--withRightBorder",
"className": "MuiDataGridPremium-cell--withRightBorder",
Expand All @@ -770,12 +764,6 @@
"description": "Styles applied to the cell checkbox element.",
"isGlobal": false
},
{
"key": "cellContent",
"className": "MuiDataGridPremium-cellContent",
"description": "Styles applied to the element that wraps the cell content.",
"isGlobal": false
},
{
"key": "cellEmpty",
"className": "MuiDataGridPremium-cellEmpty",
Expand Down Expand Up @@ -1436,6 +1424,30 @@
"description": "Styles applied to the horizontal scrollbar.",
"isGlobal": false
},
{
"key": "scrollbarFiller",
"className": "MuiDataGridPremium-scrollbarFiller",
"description": "",
"isGlobal": false
},
{
"key": "scrollbarFiller--borderTop",
"className": "MuiDataGridPremium-scrollbarFiller--borderTop",
"description": "",
"isGlobal": false
},
{
"key": "scrollbarFiller--header",
"className": "MuiDataGridPremium-scrollbarFiller--header",
"description": "",
"isGlobal": false
},
{
"key": "scrollbarFiller--pinnedRight",
"className": "MuiDataGridPremium-scrollbarFiller--pinnedRight",
"description": "",
"isGlobal": false
},
{
"key": "selectedRowCount",
"className": "MuiDataGridPremium-selectedRowCount",
Expand Down
36 changes: 24 additions & 12 deletions docs/pages/x/api/data-grid/data-grid-pro.json
Original file line number Diff line number Diff line change
Expand Up @@ -691,12 +691,6 @@
"description": "Styles applied the cell if `showColumnVerticalBorder={true}`.",
"isGlobal": false
},
{
"key": "cell--withRenderer",
"className": "MuiDataGridPro-cell--withRenderer",
"description": "Styles applied to the cell element if the cell has a custom renderer.",
"isGlobal": false
},
{
"key": "cell--withRightBorder",
"className": "MuiDataGridPro-cell--withRightBorder",
Expand All @@ -709,12 +703,6 @@
"description": "Styles applied to the cell checkbox element.",
"isGlobal": false
},
{
"key": "cellContent",
"className": "MuiDataGridPro-cellContent",
"description": "Styles applied to the element that wraps the cell content.",
"isGlobal": false
},
{
"key": "cellEmpty",
"className": "MuiDataGridPro-cellEmpty",
Expand Down Expand Up @@ -1375,6 +1363,30 @@
"description": "Styles applied to the horizontal scrollbar.",
"isGlobal": false
},
{
"key": "scrollbarFiller",
cherniavskii marked this conversation as resolved.
Show resolved Hide resolved
"className": "MuiDataGridPro-scrollbarFiller",
"description": "",
"isGlobal": false
},
{
"key": "scrollbarFiller--borderTop",
"className": "MuiDataGridPro-scrollbarFiller--borderTop",
"description": "",
"isGlobal": false
},
{
"key": "scrollbarFiller--header",
"className": "MuiDataGridPro-scrollbarFiller--header",
"description": "",
"isGlobal": false
},
{
"key": "scrollbarFiller--pinnedRight",
"className": "MuiDataGridPro-scrollbarFiller--pinnedRight",
"description": "",
"isGlobal": false
},
{
"key": "selectedRowCount",
"className": "MuiDataGridPro-selectedRowCount",
Expand Down
36 changes: 24 additions & 12 deletions docs/pages/x/api/data-grid/data-grid.json
Original file line number Diff line number Diff line change
Expand Up @@ -576,12 +576,6 @@
"description": "Styles applied the cell if `showColumnVerticalBorder={true}`.",
"isGlobal": false
},
{
"key": "cell--withRenderer",
"className": "MuiDataGrid-cell--withRenderer",
"description": "Styles applied to the cell element if the cell has a custom renderer.",
"isGlobal": false
},
{
"key": "cell--withRightBorder",
"className": "MuiDataGrid-cell--withRightBorder",
Expand All @@ -594,12 +588,6 @@
"description": "Styles applied to the cell checkbox element.",
"isGlobal": false
},
{
"key": "cellContent",
"className": "MuiDataGrid-cellContent",
"description": "Styles applied to the element that wraps the cell content.",
"isGlobal": false
},
{
"key": "cellEmpty",
"className": "MuiDataGrid-cellEmpty",
Expand Down Expand Up @@ -1260,6 +1248,30 @@
"description": "Styles applied to the horizontal scrollbar.",
"isGlobal": false
},
{
"key": "scrollbarFiller",
"className": "MuiDataGrid-scrollbarFiller",
"description": "",
"isGlobal": false
},
{
"key": "scrollbarFiller--borderTop",
"className": "MuiDataGrid-scrollbarFiller--borderTop",
"description": "",
"isGlobal": false
},
{
"key": "scrollbarFiller--header",
"className": "MuiDataGrid-scrollbarFiller--header",
"description": "",
"isGlobal": false
},
{
"key": "scrollbarFiller--pinnedRight",
"className": "MuiDataGrid-scrollbarFiller--pinnedRight",
"description": "",
"isGlobal": false
},
{
"key": "selectedRowCount",
"className": "MuiDataGrid-selectedRowCount",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -743,22 +743,13 @@
"cell--withLeftBorder": {
"description": "Styles applied the cell if <code>showColumnVerticalBorder={true}</code>."
},
"cell--withRenderer": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the cell element",
"conditions": "the cell has a custom renderer"
},
"cell--withRightBorder": {
"description": "Styles applied the cell if <code>showColumnVerticalBorder={true}</code>."
},
"cellCheckbox": {
"description": "Styles applied to {{nodeName}}.",
"nodeName": "the cell checkbox element"
},
"cellContent": {
"description": "Styles applied to {{nodeName}}.",
"nodeName": "the element that wraps the cell content"
},
"cellEmpty": {
"description": "Styles applied to {{nodeName}}.",
"nodeName": "the empty cell element"
Expand Down Expand Up @@ -1198,6 +1189,10 @@
"description": "Styles applied to {{nodeName}}.",
"nodeName": "the horizontal scrollbar"
},
"scrollbarFiller": { "description": "" },
"scrollbarFiller--borderTop": { "description": "" },
"scrollbarFiller--header": { "description": "" },
"scrollbarFiller--pinnedRight": { "description": "" },
"selectedRowCount": {
"description": "Styles applied to {{nodeName}}.",
"nodeName": "the footer selected row count element"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -685,22 +685,13 @@
"cell--withLeftBorder": {
"description": "Styles applied the cell if <code>showColumnVerticalBorder={true}</code>."
},
"cell--withRenderer": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the cell element",
"conditions": "the cell has a custom renderer"
},
"cell--withRightBorder": {
"description": "Styles applied the cell if <code>showColumnVerticalBorder={true}</code>."
},
"cellCheckbox": {
"description": "Styles applied to {{nodeName}}.",
"nodeName": "the cell checkbox element"
},
"cellContent": {
"description": "Styles applied to {{nodeName}}.",
"nodeName": "the element that wraps the cell content"
},
"cellEmpty": {
"description": "Styles applied to {{nodeName}}.",
"nodeName": "the empty cell element"
Expand Down Expand Up @@ -1140,6 +1131,10 @@
"description": "Styles applied to {{nodeName}}.",
"nodeName": "the horizontal scrollbar"
},
"scrollbarFiller": { "description": "" },
"scrollbarFiller--borderTop": { "description": "" },
"scrollbarFiller--header": { "description": "" },
"scrollbarFiller--pinnedRight": { "description": "" },
"selectedRowCount": {
"description": "Styles applied to {{nodeName}}.",
"nodeName": "the footer selected row count element"
Expand Down
13 changes: 4 additions & 9 deletions docs/translations/api-docs/data-grid/data-grid/data-grid.json
Original file line number Diff line number Diff line change
Expand Up @@ -551,22 +551,13 @@
"cell--withLeftBorder": {
"description": "Styles applied the cell if <code>showColumnVerticalBorder={true}</code>."
},
"cell--withRenderer": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the cell element",
"conditions": "the cell has a custom renderer"
},
"cell--withRightBorder": {
"description": "Styles applied the cell if <code>showColumnVerticalBorder={true}</code>."
},
"cellCheckbox": {
"description": "Styles applied to {{nodeName}}.",
"nodeName": "the cell checkbox element"
},
"cellContent": {
"description": "Styles applied to {{nodeName}}.",
"nodeName": "the element that wraps the cell content"
},
"cellEmpty": {
"description": "Styles applied to {{nodeName}}.",
"nodeName": "the empty cell element"
Expand Down Expand Up @@ -1006,6 +997,10 @@
"description": "Styles applied to {{nodeName}}.",
"nodeName": "the horizontal scrollbar"
},
"scrollbarFiller": { "description": "" },
"scrollbarFiller--borderTop": { "description": "" },
"scrollbarFiller--header": { "description": "" },
"scrollbarFiller--pinnedRight": { "description": "" },
"selectedRowCount": {
"description": "Styles applied to {{nodeName}}.",
"nodeName": "the footer selected row count element"
Expand Down
18 changes: 14 additions & 4 deletions packages/x-data-grid-generator/src/renderer/renderProgress.tsx
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

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ interface ProgressBarProps {
value: number;
}

const Root = styled('div')(({ theme }) => ({
const Center = styled('div')({
height: '100%',
display: 'flex',
alignItems: 'center',
});

const Element = styled('div')(({ theme }) => ({
border: `1px solid ${(theme.vars || theme).palette.divider}`,
position: 'relative',
overflow: 'hidden',
Expand Down Expand Up @@ -42,7 +48,7 @@ const ProgressBar = React.memo(function ProgressBar(props: ProgressBarProps) {
const valueInPercent = value * 100;

return (
<Root>
<Element>
<Value>{`${valueInPercent.toLocaleString()} %`}</Value>
<Bar
className={clsx({
Expand All @@ -52,7 +58,7 @@ const ProgressBar = React.memo(function ProgressBar(props: ProgressBarProps) {
})}
style={{ maxWidth: `${valueInPercent}%` }}
/>
</Root>
</Element>
);
});

Expand All @@ -67,5 +73,9 @@ export function renderProgress(params: GridRenderCellParams<any, number, any>) {
return null;
}

return <ProgressBar value={params.value} />;
return (
<Center>
<ProgressBar value={params.value} />
</Center>
);
}
15 changes: 12 additions & 3 deletions packages/x-data-grid-generator/src/renderer/renderRating.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,22 @@ const RatingValue = React.memo(function RatingValue(props: RatingValueProps) {
return (
<Box
sx={{
height: '100%',
display: 'flex',
alignItems: 'center',
lineHeight: '24px',
color: 'text.secondary',
justifyContent: 'flex-end',
}}
>
<Rating value={value} sx={{ mr: 1 }} readOnly /> {Math.round(Number(value) * 10) / 10}
<Box
sx={{
display: 'flex',
alignItems: 'center',
lineHeight: '24px',
color: 'text.secondary',
}}
>
<Rating value={value} sx={{ mr: 1 }} readOnly /> {Math.round(Number(value) * 10) / 10}
</Box>
</Box>
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,7 @@ function extractColumnWidths(
const cells = findGridCells(apiRef.current, column.field);

const widths = cells.map((cell) => {
const style = window.getComputedStyle(cell, null);
const paddingWidth = parseInt(style.paddingLeft, 10) + parseInt(style.paddingRight, 10);
const contentWidth = cell.firstElementChild?.getBoundingClientRect().width ?? 0;
return paddingWidth + contentWidth;
return cell.getBoundingClientRect().width ?? 0;
});

const filteredWidths = options.includeOutliers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('<DataGridPro /> - Row reorder', () => {

render(<Test />);
expect(getRowsFieldContent('brand')).to.deep.equal(['Nike', 'Adidas', 'Puma']);
const rowReorderCell = getCell(0, 0).firstChild!;
const rowReorderCell = getCell(0, 0)!;
fireEvent.dragStart(rowReorderCell);
expect(rowReorderCell).not.to.have.class(gridClasses['row--dragging']);
});
Expand Down
Loading
Loading