diff --git a/docs/src/pages/components/data-grid/events/events.json b/docs/src/pages/components/data-grid/events/events.json index 76a75d7218c0..cc88648d1a25 100644 --- a/docs/src/pages/components/data-grid/events/events.json +++ b/docs/src/pages/components/data-grid/events/events.json @@ -162,7 +162,6 @@ "description": "Fired when the user stops resizing a column. Called with an object { field: string }." }, { "name": "columnOrderChange", "description": "Fired when the user ends resizing a column." }, - { "name": "rowsClear", "description": "Fired when the grid is emptied." }, { "name": "columnsChange", "description": "Fired when the columns state is changed.\nCalled with an array of strings correspoding to the field names." diff --git a/packages/grid/_modules_/grid/constants/eventsConstants.ts b/packages/grid/_modules_/grid/constants/eventsConstants.ts index 59f17537e9e5..53d00deadcec 100644 --- a/packages/grid/_modules_/grid/constants/eventsConstants.ts +++ b/packages/grid/_modules_/grid/constants/eventsConstants.ts @@ -412,7 +412,10 @@ export const GRID_ROWS_UPDATE = 'rowsUpdate'; export const GRID_ROWS_SET = 'rowsSet'; /** - * Fired when the grid is emptied. + * Implementation detail. + * Fired to reset the sortedRow when the set of rows changes. + * It's important as the rendered rows are coming from the sortedRow + * @ignore - do not document. * @event */ export const GRID_ROWS_CLEAR = 'rowsClear'; diff --git a/packages/grid/_modules_/grid/hooks/features/filter/visibleGridRowsState.ts b/packages/grid/_modules_/grid/hooks/features/filter/visibleGridRowsState.ts index ce146386c8fd..239dca868443 100644 --- a/packages/grid/_modules_/grid/hooks/features/filter/visibleGridRowsState.ts +++ b/packages/grid/_modules_/grid/hooks/features/filter/visibleGridRowsState.ts @@ -2,7 +2,6 @@ import { GridRowId } from '../../../models/gridRows'; export interface VisibleGridRowsState { visibleRowsLookup: Record; - visibleRows?: GridRowId[]; } diff --git a/packages/grid/x-grid/src/tests/rows.XGrid.test.tsx b/packages/grid/x-grid/src/tests/rows.XGrid.test.tsx index c800f9cb5537..02d981294cdf 100644 --- a/packages/grid/x-grid/src/tests/rows.XGrid.test.tsx +++ b/packages/grid/x-grid/src/tests/rows.XGrid.test.tsx @@ -162,6 +162,7 @@ describe(' - Rows', () => { it('should allow to reset rows with setRows and render after 100ms', () => { render(); + expect(getColumnValues()).to.deep.equal(['Nike', 'Adidas', 'Puma']); const newRows = [ { id: 3, @@ -174,6 +175,14 @@ describe(' - Rows', () => { expect(getColumnValues()).to.deep.equal(['Nike', 'Adidas', 'Puma']); clock.tick(50); expect(getColumnValues()).to.deep.equal(['Asics']); + + apiRef.current.setRows(baselineProps.rows); + // Force an update before the 100ms + apiRef.current.forceUpdate(() => apiRef.current.state); + // Tradeoff, the value is YOLO + expect(getColumnValues()).to.deep.equal(['Nike']); + clock.tick(100); + expect(getColumnValues()).to.deep.equal(['Nike', 'Adidas', 'Puma']); }); it('should allow to update row data', () => {