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

[core] Clean up "autoHeight" logic #16017

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/pages/x/api/data-grid/data-grid-premium.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"type": { "name": "bool" },
"default": "false",
"deprecated": true,
"deprecationInfo": "Use flex parent container instead: <a href=\"https://mui.com/x/react-data-grid/layout/#flex-parent-container\">https://mui.com/x/react-data-grid/layout/#flex-parent-container</a>"
"deprecationInfo": "Use flex parent container instead: <a href=\"https://mui.com/r/x-grid-deprecate-auto-height\">https://mui.com/r/x-grid-deprecate-auto-height</a>."
},
"autoPageSize": { "type": { "name": "bool" }, "default": "false" },
"autosizeOnMount": { "type": { "name": "bool" }, "default": "false" },
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/x/api/data-grid/data-grid-pro.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": { "name": "bool" },
"default": "false",
"deprecated": true,
"deprecationInfo": "Use flex parent container instead: <a href=\"https://mui.com/x/react-data-grid/layout/#flex-parent-container\">https://mui.com/x/react-data-grid/layout/#flex-parent-container</a>"
"deprecationInfo": "Use flex parent container instead: <a href=\"https://mui.com/r/x-grid-deprecate-auto-height\">https://mui.com/r/x-grid-deprecate-auto-height</a>."
},
"autoPageSize": { "type": { "name": "bool" }, "default": "false" },
"autosizeOnMount": { "type": { "name": "bool" }, "default": "false" },
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/x/api/data-grid/data-grid.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": { "name": "bool" },
"default": "false",
"deprecated": true,
"deprecationInfo": "Use flex parent container instead: <a href=\"https://mui.com/x/react-data-grid/layout/#flex-parent-container\">https://mui.com/x/react-data-grid/layout/#flex-parent-container</a>"
"deprecationInfo": "Use flex parent container instead: <a href=\"https://mui.com/r/x-grid-deprecate-auto-height\">https://mui.com/r/x-grid-deprecate-auto-height</a>."
},
"autoPageSize": { "type": { "name": "bool" }, "default": "false" },
"autosizeOnMount": { "type": { "name": "bool" }, "default": "false" },
Expand Down
1 change: 1 addition & 0 deletions docs/public/_redirects
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
/r/x-pro-svg-link https://mui.com/x/introduction/licensing/#pro-plan 302
/r/x-premium-svg https://mui.com/static/x/premium.svg 302
/r/x-premium-svg-link https://mui.com/x/introduction/licensing/#premium-plan 302
/r/x-grid-deprecate-auto-height https://mui.com/x/react-data-grid/layout/#flex-parent-container 302

# Legacy redirection
# Added in chronological order (the last line is the most recent one)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ DataGridPremiumRaw.propTypes = {
/**
* If `true`, the Data Grid height is dynamic and follows the number of rows in the Data Grid.
* @default false
* @deprecated Use flex parent container instead: https://mui.com/x/react-data-grid/layout/#flex-parent-container
* @deprecated Use flex parent container instead: https://mui.com/r/x-grid-deprecate-auto-height.
* @example
* <div style={{ display: 'flex', flexDirection: 'column' }}>
* <DataGrid />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ import {
} from '@mui/x-data-grid-premium';
import { getColumnValues } from 'test/utils/helperFn';

const isJSDOM = /jsdom/.test(window.navigator.userAgent);

describe('<DataGrid /> - Quick filter', () => {
const { render } = createRenderer();

const baselineProps = {
autoHeight: isJSDOM,
disableVirtualization: true,
rows: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import { expect } from 'chai';
import Excel from 'exceljs';
import { spyApi } from 'test/utils/helperFn';

const isJSDOM = /jsdom/.test(window.navigator.userAgent);

describe('<DataGridPremium /> - Export Excel', () => {
const { render } = createRenderer();

Expand All @@ -39,7 +37,6 @@ describe('<DataGridPremium /> - Export Excel', () => {
const baselineProps = {
columns,
rows,
autoHeight: isJSDOM,
};

function TestCaseExcelExport(props: Partial<DataGridPremiumProps>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ describe('<DataGridPremium /> - License', () => {
planVersion: 'initial',
}),
);
expect(() => render(<DataGridPremium columns={[]} rows={[]} autoHeight />)).toErrorDev([
expect(() => render(<DataGridPremium columns={[]} rows={[]} />)).toErrorDev([
'MUI X: License key plan mismatch',
]);
});

it('should render watermark when the license is missing', async () => {
LicenseInfo.setLicenseKey('');

expect(() => render(<DataGridPremium columns={[]} rows={[]} autoHeight />)).toErrorDev([
expect(() => render(<DataGridPremium columns={[]} rows={[]} />)).toErrorDev([
'MUI X: Missing license key.',
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ import {
} from '@mui/x-data-grid-premium';
import { spy } from 'sinon';

const isJSDOM = /jsdom/.test(window.navigator.userAgent);

interface BaselineProps extends DataGridPremiumProps {
rows: GridRowsProp;
}
Expand All @@ -58,7 +56,6 @@ const unbalancedRows: GridRowsProp = [
];

const baselineProps: BaselineProps = {
autoHeight: isJSDOM,
disableVirtualization: true,
rows,
columns: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import {
gridClasses,
} from '@mui/x-data-grid-premium';

const isJSDOM = /jsdom/.test(window.navigator.userAgent);

const rows: GridRowsProp = [
{ id: 0, category1: 'Cat A', category2: 'Cat 1' },
{ id: 1, category1: 'Cat A', category2: 'Cat 2' },
Expand All @@ -19,7 +17,6 @@ const rows: GridRowsProp = [
];

const baselineProps: DataGridPremiumProps = {
autoHeight: isJSDOM,
disableVirtualization: true,
rows,
columns: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import {
useGridApiRef,
} from '@mui/x-data-grid-premium';

const isJSDOM = /jsdom/.test(window.navigator.userAgent);

interface BaselineProps extends DataGridPremiumProps {
rows: GridRowsProp;
}
Expand All @@ -26,7 +24,6 @@ const rows: GridRowsProp = [
];

const baselineProps: BaselineProps = {
autoHeight: isJSDOM,
disableVirtualization: true,
rows,
columns: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import { createRenderer, act } from '@mui/internal-test-utils';
import { expect } from 'chai';
import { getColumnValues } from 'test/utils/helperFn';

const isJSDOM = /jsdom/.test(window.navigator.userAgent);

const rows: GridRowsProp = [
{ id: 0, category: 'Cat A' },
{ id: 1, category: 'Cat A' },
Expand Down Expand Up @@ -61,7 +59,6 @@ describe('<DataGridPremium /> - State persistence', () => {
rows={rows}
columns={columns}
pagination
autoHeight={isJSDOM}
apiRef={apiRef}
disableVirtualization
{...props}
Expand Down
2 changes: 1 addition & 1 deletion packages/x-data-grid-pro/src/DataGridPro/DataGridPro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ DataGridProRaw.propTypes = {
/**
* If `true`, the Data Grid height is dynamic and follows the number of rows in the Data Grid.
* @default false
* @deprecated Use flex parent container instead: https://mui.com/x/react-data-grid/layout/#flex-parent-container
* @deprecated Use flex parent container instead: https://mui.com/r/x-grid-deprecate-auto-height.
* @example
* <div style={{ display: 'flex', flexDirection: 'column' }}>
* <DataGrid />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ describe('<DataGridPro /> - Cell editing', () => {
});

it(`should not publish 'cellEditStart' if space is pressed`, () => {
render(<TestCase autoHeight />);
render(<TestCase />);
const listener = spy();
apiRef.current.subscribeEvent('cellEditStart', listener);
const cell = getCell(0, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@ import { SinonSpy, spy } from 'sinon';
import { getCell } from 'test/utils/helperFn';
import { fireUserEvent } from 'test/utils/fireUserEvent';

const isJSDOM = /jsdom/.test(window.navigator.userAgent);

describe('<DataGridPro /> - Clipboard', () => {
const { render } = createRenderer();

const baselineProps = {
autoHeight: isJSDOM,
};
const baselineProps = {};

const columns = [{ field: 'id' }, { field: 'brand', headerName: 'Brand' }];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ describe('<DataGridPro /> - Column headers', () => {
const { render, clock } = createRenderer({ clock: 'fake' });

const baselineProps = {
autoHeight: isJSDOM,
disableColumnResize: false,
rows: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import { useGridApiRef, DataGridPro, gridClasses, GridApi } from '@mui/x-data-gr
import { useBasicDemoData } from '@mui/x-data-grid-generator';
import { spy } from 'sinon';

const isJSDOM = /jsdom/.test(window.navigator.userAgent);

function createDragOverEvent(target: ChildNode) {
const dragOverEvent = createEvent.dragOver(target);
// Safari 13 doesn't have DragEvent.
Expand All @@ -36,7 +34,6 @@ describe('<DataGridPro /> - Columns reorder', () => {
const { render } = createRenderer();

const baselineProps = {
autoHeight: isJSDOM,
rows: [
{
id: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ describe('<DataGridPro /> - Columns', () => {
let apiRef: React.MutableRefObject<GridApi>;

const baselineProps = {
autoHeight: isJSDOM,
rows: [
{ id: 0, brand: 'Nike' },
{ id: 1, brand: 'Adidas' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import {
} from '@mui/x-data-grid-pro';
import { getColumnHeadersTextContent } from 'test/utils/helperFn';

const isJSDOM = /jsdom/.test(window.navigator.userAgent);

const rows: GridRowsProp = [{ id: 1 }];

const columns: GridColDef[] = [{ field: 'id' }, { field: 'idBis' }];
Expand All @@ -34,13 +32,7 @@ describe('<DataGridPro /> - Columns visibility', () => {

return (
<div style={{ width: 300, height: 300 }}>
<DataGridPro
columns={columns}
rows={rows}
{...props}
apiRef={apiRef}
autoHeight={isJSDOM}
/>
<DataGridPro columns={columns} rows={rows} {...props} apiRef={apiRef} />
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ describe('<DataGridPro /> - Detail panel', () => {
const getDetailPanelHeight = spy(() => 100);
const { setProps } = render(
<TestCase
autoHeight
Copy link
Member

Choose a reason for hiding this comment

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

this should also be removed, no?

Copy link
Member Author

Choose a reason for hiding this comment

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

Some of the tests failed. I tried to remove as many as I could.

columns={[{ field: 'brand' }]}
rows={[
{ id: 0, brand: 'Nike' },
Expand All @@ -399,7 +400,6 @@ describe('<DataGridPro /> - Detail panel', () => {
pagination
pageSizeOptions={[1]}
initialState={{ pagination: { paginationModel: { pageSize: 1 } } }}
autoHeight
/>,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ import { createRenderer, act } from '@mui/internal-test-utils';
import { expect } from 'chai';
import * as React from 'react';

const isJSDOM = /jsdom/.test(window.navigator.userAgent);

describe('<DataGridPro /> - Export', () => {
const { render } = createRenderer();

const baselineProps = {
autoHeight: isJSDOM,
};
const baselineProps = {};

let apiRef: React.MutableRefObject<GridApi>;

Expand Down Expand Up @@ -549,7 +545,7 @@ describe('<DataGridPro /> - Export', () => {
apiRef = useGridApiRef();
return (
<div style={{ width: 300 }}>
<DataGridPro apiRef={apiRef} autoHeight {...defaultProps} {...props} />
<DataGridPro apiRef={apiRef} {...defaultProps} {...props} />
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ import {
} from '@mui/x-data-grid-pro';
import { createRenderer, act } from '@mui/internal-test-utils';

const isJSDOM = /jsdom/.test(window.navigator.userAgent);

describe('<DataGrid /> - Filter panel', () => {
const { render } = createRenderer();

const baselineProps: DataGridProProps = {
autoHeight: isJSDOM,
disableVirtualization: true,
rows: [],
columns: [{ field: 'brand' }],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ describe('<DataGridPro /> - Filter', () => {
let apiRef: React.MutableRefObject<GridApi>;

const baselineProps = {
autoHeight: isJSDOM,
rows: [
{
id: 0,
Expand Down Expand Up @@ -886,7 +885,6 @@ describe('<DataGridPro /> - Filter', () => {
return (
<div style={{ width: 300, height: 300 }}>
<DataGridPro
autoHeight={isJSDOM}
columns={columns || baselineProps.columns}
rows={rows || baselineProps.rows}
filterModel={caseFilterModel}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe('<DataGridPro /> - Lazy loader', () => {

// See https://github.com/mui/mui-x/issues/6857
it('should update the row when `apiRef.current.updateRows` is called on lazy-loaded rows', () => {
render(<TestLazyLoader rowCount={5} autoHeight={isJSDOM} />);
render(<TestLazyLoader rowCount={5} />);

const newRows: GridRowModel[] = [
{ id: 4, first: 'John' },
Expand Down Expand Up @@ -171,7 +171,7 @@ describe('<DataGridPro /> - Lazy loader', () => {
});

it('should update rows when `apiRef.current.updateRows` with data reversed', () => {
render(<TestLazyLoader rowCount={5} autoHeight={isJSDOM} />);
render(<TestLazyLoader rowCount={5} />);

const newRows: GridRowModel[] = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('<DataGridPro /> - License', () => {
it('should render watermark when the license is missing', async () => {
LicenseInfo.setLicenseKey('');

expect(() => render(<DataGridPro columns={[]} rows={[]} autoHeight />)).toErrorDev([
expect(() => render(<DataGridPro columns={[]} rows={[]} />)).toErrorDev([
'MUI X: Missing license key.',
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ describe('<DataGridPro /> - Row editing', () => {
});

it('should not call startRowEditMode if space is pressed', () => {
render(<TestCase autoHeight />);
render(<TestCase />);
const listener = spy();
apiRef.current.subscribeEvent('rowEditStart', listener);
const cell = getCell(0, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe('<DataGridPro /> - Row pinning', () => {

return (
<div style={{ width: 302, height: 300 }}>
<DataGridPro {...data} autoHeight pinnedRows={pinnedRows} />
<DataGridPro {...data} pinnedRows={pinnedRows} />
</div>
);
}
Expand Down
Loading
Loading