Skip to content

Commit

Permalink
fix: auto-scroll bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kswenson committed Jul 28, 2024
1 parent e2a1776 commit a25cc7a
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions packages/core/src/hooks/utilities/useRects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a25cc7a

Please sign in to comment.