Skip to content

Commit

Permalink
Fix autoresize
Browse files Browse the repository at this point in the history
  • Loading branch information
matttdawson committed May 23, 2024
1 parent aa6971a commit 38f8074
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/components/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ export const Grid = ({
const hasSetContentSizeEmpty = useRef(false);
const needsAutoSize = useRef(true);

const lastFullResize = useRef<number>();

const setInitialContentSize = useCallback(() => {
if (!gridDivRef.current?.clientWidth || rowData == null) {
// Don't resize grids if they are offscreen as it doesn't work.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 38f8074

Please sign in to comment.