Skip to content

Commit

Permalink
[DataGrid] Fix events naming (#1862)
Browse files Browse the repository at this point in the history
  • Loading branch information
m4theushw authored and oliviertassinari committed Jun 21, 2021
1 parent 1210f1a commit 1f8609f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
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

0 comments on commit 1f8609f

Please sign in to comment.