diff --git a/.changeset/thin-walls-remain.md b/.changeset/thin-walls-remain.md new file mode 100644 index 00000000..ffa6c4d6 --- /dev/null +++ b/.changeset/thin-walls-remain.md @@ -0,0 +1,5 @@ +--- +'@dnd-kit/core': patch +--- + +Fix a bug with auto-scroller continuing to observe stale elements, causing them to be considered as scrollable. diff --git a/packages/core/src/hooks/utilities/useRects.ts b/packages/core/src/hooks/utilities/useRects.ts index 9bd4f58a..caf2ad78 100644 --- a/packages/core/src/hooks/utilities/useRects.ts +++ b/packages/core/src/hooks/utilities/useRects.ts @@ -36,17 +36,10 @@ export function useRects( 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;