From 48d4711844f7baebd9d10a86cb6cf10d0aa27e6c Mon Sep 17 00:00:00 2001 From: Tal Koren Date: Tue, 24 Dec 2024 10:12:26 +0200 Subject: [PATCH] fix(VirtualizedGrid): fix onItemsRendered params (#2674) --- .../components/VirtualizedGrid/VirtualizedGrid.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/core/src/components/VirtualizedGrid/VirtualizedGrid.tsx b/packages/core/src/components/VirtualizedGrid/VirtualizedGrid.tsx index 72cfc30685..fafe44c4f6 100644 --- a/packages/core/src/components/VirtualizedGrid/VirtualizedGrid.tsx +++ b/packages/core/src/components/VirtualizedGrid/VirtualizedGrid.tsx @@ -1,6 +1,12 @@ import React, { CSSProperties, forwardRef, useCallback, useEffect, useMemo, useRef, useState } from "react"; import cx from "classnames"; -import { GridChildComponentProps, GridOnScrollProps, ScrollDirection, VariableSizeGrid as Grid } from "react-window"; +import { + GridChildComponentProps, + GridOnScrollProps, + ScrollDirection, + VariableSizeGrid as Grid, + GridOnItemsRenderedProps +} from "react-window"; import AutoSizer from "react-virtualized-auto-sizer"; import { getNormalizedItems, @@ -209,14 +215,14 @@ const VirtualizedGrid: VibeComponent = forwardRef( ); const onItemsRenderedCB = useThrottledCallback( - ({ visibleStartIndex, visibleStopIndex }) => { + ({ visibleRowStartIndex, visibleRowStopIndex }: GridOnItemsRenderedProps) => { if (!onItemsRendered) return; const data = getOnItemsRenderedData( items, normalizedItems, idGetter, - visibleStartIndex, - visibleStopIndex, + visibleRowStartIndex, + visibleRowStopIndex, gridHeight, scrollTopRef.current );