From 38f8074d6eb9120d355bca4ca94b41493f00f3dd Mon Sep 17 00:00:00 2001 From: matttdawson <89495499+matttdawson@users.noreply.github.com> Date: Thu, 23 May 2024 15:31:32 +1200 Subject: [PATCH] Fix autoresize --- src/components/Grid.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/Grid.tsx b/src/components/Grid.tsx index f14d4cac..ef662b39 100644 --- a/src/components/Grid.tsx +++ b/src/components/Grid.tsx @@ -165,6 +165,8 @@ export const Grid = ({ const hasSetContentSizeEmpty = useRef(false); const needsAutoSize = useRef(true); + const lastFullResize = useRef(); + const setInitialContentSize = useCallback(() => { if (!gridDivRef.current?.clientWidth || rowData == null) { // Don't resize grids if they are offscreen as it doesn't work. @@ -193,8 +195,13 @@ export const Grid = ({ } } else if (gridRendered === "rows-visible") { if (!hasSetContentSize.current) { - hasSetContentSize.current = true; - params.onContentSize?.(result); + if (lastFullResize.current === result.width) { + hasSetContentSize.current = true; + params.onContentSize?.(result); + } else { + needsAutoSize.current = true; + } + lastFullResize.current = result.width; } } else { // It should be impossible to get here