From 4e930b9e8f253eea663fa1c9b6b17aa8723fd80b Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Tue, 25 Nov 2025 12:03:56 +0100 Subject: [PATCH] fix: ensure each block animations don't mess with transitions This ensures that an animation does not run when the element is first transitioning in. Else the animation would mess with the transition (overriding its animation basically). Due to our test setup it's not testable but I veryfied it fixes #17181 (tested all reproductions in there) --- .changeset/tiny-loops-wonder.md | 5 +++++ packages/svelte/src/internal/client/dom/blocks/each.js | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 .changeset/tiny-loops-wonder.md diff --git a/.changeset/tiny-loops-wonder.md b/.changeset/tiny-loops-wonder.md new file mode 100644 index 000000000000..49ac92947c61 --- /dev/null +++ b/.changeset/tiny-loops-wonder.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: ensure each block animations don't mess with transitions diff --git a/packages/svelte/src/internal/client/dom/blocks/each.js b/packages/svelte/src/internal/client/dom/blocks/each.js index 320c0346902c..6e538f8f2177 100644 --- a/packages/svelte/src/internal/client/dom/blocks/each.js +++ b/packages/svelte/src/internal/client/dom/blocks/each.js @@ -394,8 +394,12 @@ function reconcile(state, array, anchor, flags, get_key) { key = get_key(value, i); item = /** @type {EachItem} */ (items.get(key)); - item.a?.measure(); - (to_animate ??= new Set()).add(item); + // offscreen == coming in now, no animation in that case, + // else this would happen https://github.com/sveltejs/svelte/issues/17181 + if (item.o) { + item.a?.measure(); + (to_animate ??= new Set()).add(item); + } } }