-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
fix: link offscreen items and last effect in each block correctly #17240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
It's possible that due to how new elements are inserted into the array that `effect.last` is wrong. We need to ensure it is really the last item to keep items properly connected to the graph. In addition we link offscreen items after all onscreen items, to ensure they don't have wrong pointers. Fixes #17201
🦋 Changeset detectedLatest commit: 3058046 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
|
I think the fix should be in |
|
While digging into this I built a stress test that checks whether reconciliation succeeds and effects remaining linked to the tree. It turns out that there are some tricky bugs around transitions that are unaffected by this PR; I aim to investigate those next. In the meantime, it looks like this PR succeeds where |
It's possible that due to how new elements are inserted into the array that
effect.lastis wrong. We need to ensure it is really the last item to keep items properly connected to the graph. In addition we link offscreen items after all onscreen items, to ensure they don't have wrong pointers.#17244 as an alternative didn't work because it is possible due to how we don't link all items during reconciliation to end up with the wrong
effect.last, which subsequently can mean that an item "falls out" of the graph. The added test showcases how this goes wrong with the previous logic:[1, 2, 3]4-> is noweffect.last[1, 4, 2, 3]->effect.lastnow2(not3because that isn't relinked because the order didn't change and reconciliation sees that)5-> is noweffect.last, which means2.nextis now5and no longer3effect.lastnow2again -> noone has3asnext->3fell out of the graph3-> nothing happensThe fix is to go back to the behavior prior to #17150 which is "set the last item as
last", additionally taking into account offscreen items.Fixes #17201
Fixes #17239
Before submitting the PR, please make sure you do the following
feat:,fix:,chore:, ordocs:.packages/svelte/src, add a changeset (npx changeset).Tests and linting
pnpm testand lint the project withpnpm lint