From a25cc7a3fc1c4cf51ba703c3fad0c20c5b84c603 Mon Sep 17 00:00:00 2001 From: Kirk Swenson Date: Sun, 28 Jul 2024 06:55:00 -0700 Subject: [PATCH] fix: auto-scroll bug --- packages/core/src/hooks/utilities/useRects.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/packages/core/src/hooks/utilities/useRects.ts b/packages/core/src/hooks/utilities/useRects.ts index 97a56e2f..a430c548 100644 --- a/packages/core/src/hooks/utilities/useRects.ts +++ b/packages/core/src/hooks/utilities/useRects.ts @@ -21,17 +21,10 @@ export function useRects( const [rects, measureRects] = useReducer(reducer, defaultValue); const resizeObserver = useResizeObserver({callback: measureRects}); - if (elements.length > 0 && rects === defaultValue) { - measureRects(); - } - useIsomorphicLayoutEffect(() => { - if (elements.length) { - elements.forEach((element) => resizeObserver?.observe(element)); - } else { - resizeObserver?.disconnect(); - measureRects(); - } + resizeObserver?.disconnect(); + measureRects(); + elements.forEach((element) => resizeObserver?.observe(element)); }, [elements]); return rects;