Skip to content

Commit

Permalink
[DataGrid] Initialize apiRef early (#11792)
Browse files Browse the repository at this point in the history
  • Loading branch information
cherniavskii authored Jan 23, 2024
1 parent 4e9553d commit 49587c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ export function useGridApiInitialization<

useGridApiMethod(privateApiRef, { subscribeEvent, publishEvent } as any, 'public');

if (inputApiRef && !inputApiRef.current?.state) {
inputApiRef.current = publicApiRef.current;
}

React.useImperativeHandle(inputApiRef, () => publicApiRef.current, [publicApiRef]);

React.useEffect(() => {
Expand Down
2 changes: 2 additions & 0 deletions packages/grid/x-data-grid/src/tests/rows.DataGrid.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
getRow,
getActiveCell,
getCell,
microtasks,
} from 'test/utils/helperFn';
import Dialog from '@mui/material/Dialog';

Expand Down Expand Up @@ -311,6 +312,7 @@ describe('<DataGrid /> - Rows', () => {
await waitFor(() => {
expect(getRow(0)).not.to.have.class('Mui-selected');
});
await microtasks();
});

it('should not select the row when opening the menu', async () => {
Expand Down

0 comments on commit 49587c6

Please sign in to comment.