Skip to content

Commit 53a387a

Browse files
[DataGrid] Do not debounce the initial resizing of the grid (#3213)
1 parent e126eb9 commit 53a387a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/grid/_modules_/grid/hooks/features/dimensions/useGridDimensions.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ export function useGridDimensions(
176176

177177
const debounceResize = React.useMemo(() => debounce(resize, 60), [resize]);
178178

179+
const isFirstSizing = React.useRef(true);
180+
179181
const handleResize = React.useCallback(
180182
(size: ElementSize) => {
181183
rootDimensionsRef.current = size;
@@ -213,6 +215,14 @@ export function useGridDimensions(
213215
if (isTestEnvironment) {
214216
// We don't need to debounce the resize for tests.
215217
resize();
218+
isFirstSizing.current = false;
219+
return;
220+
}
221+
222+
if (isFirstSizing.current) {
223+
// We want to initialize the grid dimensions as soon as possible to avoid flickering
224+
resize();
225+
isFirstSizing.current = false;
216226
return;
217227
}
218228

0 commit comments

Comments
 (0)