Repository navigation
fix(virtual-core): drop rows that a render detaches after their ref callback - #1412
Conversation
…allback 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 detectedLatest commit: f6e1ee0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
View your CI Pipeline Execution ↗ for commit f6e1ee0
💡 With Ultracache enabled, Nx Cloud learns each task's file inputs in CI and uses them on later runs. Turn on Ultracache in workspace settings ↗ · Read docs ↗ ☁️ Nx Cloud last updated this comment at |
|
Merged, thanks @jrandolf! Really nice work on this one, the repro page and the e2e case for the scroll element observer made it easy to check. |
🎯 Changes
A virtualized list logs "ResizeObserver loop completed with undelivered notifications." when it shrinks and a render in the ResizeObserver delivery unmounts rows.
A framework clears the ref of a row before it detaches the row, so
measureElement(null)still observes the last row to leave.measureElement(null)also queues one microtask that drops the rows that have left the page by then.Related: #1345, fixed by #1348. #1348 drops detached rows after a synchronous render in the row observer only.
That drop runs before a render in a microtask, and the scroll element's observer has no drop.
Reproduction, with Vue 3.5.22 and
@tanstack/vue-virtual3.13.55 (@tanstack/virtual-core3.19.14):document.documentElement.style.setProperty('--viewport', '300px')in the console.In Chromium 159, Firefox 159 and WebKit 27.2, this page logs the error in 20 of 20 runs on
main(f78d04a) and in 0 of 20 runs with this change.Three unit tests in
measurement.test.tsand the new case inresize-delivery.spec.tsfail without the change.✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit