From 43ab38db721ce0c2a46abcf4cd2992e15e279fd2 Mon Sep 17 00:00:00 2001 From: sk1982 Date: Sat, 13 Apr 2024 02:26:48 -0400 Subject: [PATCH] fix: window scroller grid remeasure on size change --- src/components/window-scroller-grid.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/window-scroller-grid.tsx b/src/components/window-scroller-grid.tsx index a0489d7..5284a66 100644 --- a/src/components/window-scroller-grid.tsx +++ b/src/components/window-scroller-grid.tsx @@ -1,4 +1,4 @@ -import { ReactNode, useRef } from 'react'; +import { ReactNode, useEffect, useRef } from 'react'; import { useWindowVirtualizer } from '@tanstack/react-virtual'; import { useResizeObserver } from 'usehooks-ts'; @@ -26,6 +26,10 @@ export const WindowScrollerGrid = ({ rowSize, colSize, items, chi overscan: 5, scrollingDelay: 0 }); + + useEffect(() => { + virtualizer.measure(); + }, [rowSize, colSize, virtualizer]); return (
{width > 0 &&