Skip to content

Commit e4fefc2

Browse files
committed
fix: fix layout calc for virtual scroll
1 parent b107676 commit e4fefc2

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

packages/shared/widget-plugin-grid/src/components/InfiniteBody.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { useOnScreen } from "@mendix/widget-plugin-hooks/useOnScreen";
2+
import classNames from "classnames";
13
import {
24
CSSProperties,
35
PropsWithChildren,
@@ -8,8 +10,6 @@ import {
810
useRef,
911
useState
1012
} from "react";
11-
import classNames from "classnames";
12-
import { useOnScreen } from "@mendix/widget-plugin-hooks/useOnScreen";
1313

1414
export interface InfiniteBodyProps {
1515
className?: string;
@@ -55,8 +55,10 @@ export function useInfiniteControl(
5555
}, [isInfinite, hasMoreItems, bodySize, isVisible]);
5656

5757
useLayoutEffect(() => {
58-
setTimeout(() => calculateBodyHeight(), 100);
59-
}, [calculateBodyHeight]);
58+
if (bodySize <= 0) {
59+
calculateBodyHeight();
60+
}
61+
});
6062

6163
return [trackScrolling, bodySize, containerRef];
6264
}

0 commit comments

Comments
 (0)