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] Make GRID_ROWS_CLEAR private #1925

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/src/pages/components/data-grid/events/events.json
Expand Up @@ -162,7 +162,6 @@
"description": "Fired when the user stops resizing a column. Called with an object <code>{ field: string }</code>."
},
{ "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."
Expand Down
5 changes: 4 additions & 1 deletion packages/grid/_modules_/grid/constants/eventsConstants.ts
Expand Up @@ -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';
Expand Down
Expand Up @@ -2,7 +2,6 @@ import { GridRowId } from '../../../models/gridRows';

export interface VisibleGridRowsState {
visibleRowsLookup: Record<GridRowId, boolean>;

visibleRows?: GridRowId[];
}

Expand Down
9 changes: 9 additions & 0 deletions packages/grid/x-grid/src/tests/rows.XGrid.test.tsx
Expand Up @@ -162,6 +162,7 @@ describe('<XGrid /> - Rows', () => {

it('should allow to reset rows with setRows and render after 100ms', () => {
render(<TestCase />);
expect(getColumnValues()).to.deep.equal(['Nike', 'Adidas', 'Puma']);
const newRows = [
{
id: 3,
Expand All @@ -174,6 +175,14 @@ describe('<XGrid /> - 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', () => {
Expand Down