Closed robertadamsonsmith closed 5 days ago
We experience the exact same bug while using the |global
modifier in the transition. Are there any updates on this issue or does a workaround exist? (of course expect removing all transitions 😉)
Fixed in Svelte 5
Describe the bug
There are two related bugs. During an outro in a parent component, if the child component has a variable invalidated which an
#if
block is dependant on, and the#if
block contains an element with its own transition, then either:|local
, the intro transition will unexpectedly start playing|global
, the parents outro will very unexpectedly stall at the end, leaving all elements visible and unmounted(REPLs below)
There are several issues that are ultimately due to this, and I've encountered both bugs myself, so I think it could be quite widespread: https://github.com/sveltejs/svelte/issues/8606 https://github.com/sveltejs/svelte/issues/8351 https://github.com/sveltejs/svelte/issues/5268 https://github.com/sveltejs/svelte/issues/9186
It appears that the first bug occurs because when the transition is
|local
the generated fragment doesn't trackcurrent
so that when the up()
date function calls transition_in, it is unable to early exit thei()
ntro. It does actually do that correctly when|global
is used though, so it might just be a case of using that logic more generally.I'm not yet sure why the second bug is occurring, but I assume the logic is highly related.
Reproduction
This is the minimal test case that demonstrates the first behaviour: https://svelte.dev/repl/b558e1303d1f45848b4dffc765c806dc?version=4.2.0
App.svelte
Child.svelte
The requirements are as follows:
transition:
element, and the child componenttransition:
element (note that the conditional block can even be 'fixed' to always be true, so the value of the variable doesn't matter, only that it has been invalidated)The second bug can be demonstrated by just changing the Child transition to
|global
: https://svelte.dev/repl/74b66e56366c491baf37f4baa4a1c347?version=4.2.0This has the following effect:
Logs
No response
System Info
Severity
annoyance