fix(solid-virtual): defer non-sync onChange updates to a microtask - #1261
Draft
moreal wants to merge 2 commits into
Draft
fix(solid-virtual): defer non-sync onChange updates to a microtask#1261moreal wants to merge 2 commits into
moreal wants to merge 2 commits into
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
- avoids reconciling the item store while <For> is iterating it Assisted-by: choco-pi:claude-opus-5 Signed-off-by: Lee Dogeon <dev.moreal@gmail.com>
- jsdom render; pre-fix adapter throws the reported TypeError Assisted-by: choco-pi:claude-opus-5 Signed-off-by: Lee Dogeon <dev.moreal@gmail.com>
moreal
force-pushed
the
fix/solid-defer-non-sync-onchange
branch
from
August 27, 2026 16:51
f10ae18 to
7bc2dec
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Changes
The Solid adapter applies every
onChangeimmediately, including the ones virtual-core reports withsync: false. Those come fromresizeItem()/measure(), which a row triggers from its own ref — while<For>is still iterating the virtual item store.reconcilethen mutates that array in place,mapArrayreads past the shortened array, and the row callback receivesundefined:virtual-core already distinguishes the two cases, and react-virtual acts on it (
flushSync(rerender)whensync, plainrerender()otherwise). The Solid adapter receivedsyncand only forwarded it to the user callback.This applies the same distinction: scroll-driven updates stay synchronous, size changes are flushed in a microtask — after the current pass, before paint. Option changes (
count,scrollMargin, …) also stay synchronous, since they run in Solid's reactive update phase rather than mid-render.Behavior change: reading
getVirtualItems()/getTotalSize()in the same tick asresizeItem()ormeasure()now returns the previous value. Reading before the re-render gives the same result in React, so this makes the adapters consistent. One existing test asserted the old timing and was updated.tests/measure-during-render.test.tsxrenders a<For>list with a measuring row ref and fails with the exception above without this change. The ref writesdata-indexbefore measuring because Solid emits_$use(ref, el)ahead of_$setAttribute(#930) — that workaround is what Solid consumers have to write today for measurement to run at all.Related: #1216 and #790 touch the same
onChangeblock. Neither fixes this — I applied #1216's change (droppingreconcile) locally and the reproduction still throws, because the problem is when the store is written, not how it is diffed.✅ Checklist
pnpm run test:pr.🚀 Release Impact