diff --git a/packages/react-aria/src/virtualizer/ScrollView.tsx b/packages/react-aria/src/virtualizer/ScrollView.tsx index 462bbec1f8e..cc6ad83e86f 100644 --- a/packages/react-aria/src/virtualizer/ScrollView.tsx +++ b/packages/react-aria/src/virtualizer/ScrollView.tsx @@ -94,7 +94,8 @@ export function useScrollView(props: ScrollViewProps, ref: RefObject | null, - isScrolling: false + isScrolling: false, + lastVisibleRect: new Rect() }).current; let {direction} = useLocale(); @@ -105,7 +106,7 @@ export function useScrollView(props: ScrollViewProps, ref: RefObject 0 || state.lastVisibleRect.area > 0) { + onVisibleRectChange(visibleRect); + state.lastVisibleRect = visibleRect; + } }, [state, allowsWindowScrolling, onVisibleRectChange]); let [isScrolling, setScrolling] = useState(false); diff --git a/packages/react-stately/src/layout/ListLayout.ts b/packages/react-stately/src/layout/ListLayout.ts index 31a2416651e..8265068a62c 100644 --- a/packages/react-stately/src/layout/ListLayout.ts +++ b/packages/react-stately/src/layout/ListLayout.ts @@ -193,8 +193,10 @@ export class ListLayout exte let rowHeight = (this.rowSize ?? this.estimatedRowSize ?? DEFAULT_HEIGHT) + this.gap; // Clone only before mutating rect = rect.copy(); - rect[offsetProperty] = Math.floor(rect[offsetProperty] / rowHeight) * rowHeight; - rect[heightProperty] = Math.ceil(rect[heightProperty] / rowHeight) * rowHeight; + let offset = Math.floor(rect[offsetProperty] / rowHeight) * rowHeight; + let height = rect[heightProperty] + rect[offsetProperty] - offset; + rect[offsetProperty] = offset; + rect[heightProperty] = Math.ceil(height / rowHeight) * rowHeight; } // If layout hasn't yet been done for the requested rect, union the