From 31e862fefa149bdbddf29873b8e44911b9dd1a2d Mon Sep 17 00:00:00 2001 From: Randolf Jung Date: Sun, 29 Nov 2026 20:29:45 -0800 Subject: [PATCH 1/2] fix(virtual-core): drop rows that a render detaches after their ref callback A framework clears a row's ref before it detaches the row's element, so `measureElement(null)` found the last unmounted row still connected and kept observing it. When a render runs in a microtask of a ResizeObserver delivery (Vue, Lit, Svelte), the row is then detached and observed at the end of the delivery, and the browser reports "ResizeObserver loop completed with undelivered notifications". The scroll element's observer and the row observer of a framework that renders in a microtask both hit this. `measureElement(null)` now also queues one microtask that drops the rows that are detached by then. The microtask runs after the render and before the browser gathers the next observations. --- .changeset/quiet-detached-rows.md | 5 + .../e2e/app/resize-delivery/index.html | 1 + .../e2e/app/resize-delivery/main.tsx | 6 +- .../e2e/app/test/resize-delivery.spec.ts | 60 ++++++-- packages/virtual-core/src/index.ts | 31 +++- .../virtual-core/tests/measurement.test.ts | 142 ++++++++++++++++++ 6 files changed, 228 insertions(+), 17 deletions(-) create mode 100644 .changeset/quiet-detached-rows.md diff --git a/.changeset/quiet-detached-rows.md b/.changeset/quiet-detached-rows.md new file mode 100644 index 000000000..202ba5d4f --- /dev/null +++ b/.changeset/quiet-detached-rows.md @@ -0,0 +1,5 @@ +--- +'@tanstack/virtual-core': patch +--- + +Fix the ResizeObserver loop error when a list shrinks in a framework that renders in a microtask, such as Vue: a row that the framework detaches right after it clears the row's ref is now unobserved before the browser delivers again. diff --git a/packages/react-virtual/e2e/app/resize-delivery/index.html b/packages/react-virtual/e2e/app/resize-delivery/index.html index 935d2619b..057ddba41 100644 --- a/packages/react-virtual/e2e/app/resize-delivery/index.html +++ b/packages/react-virtual/e2e/app/resize-delivery/index.html @@ -5,6 +5,7 @@