-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Rapidly toggling element with out: transition causes incorrect node removal #13681
Comments
Hello, It seems that the problem come from these lines : svelte/packages/svelte/src/internal/client/dom/elements/transitions.js Lines 345 to 351 in c73c683
=> The dummy animation with a delay of 0 instantly gets the 'finished' status. I managed to reproduce the scenario in this REPL : the onfinish() is called even if the animation is cancelled before ! Adding this line at the beginning of if (animation.playState === 'idle') return; But I don't known if this is enough, neither how to create a test for this ! |
Another solution could be to use a small but non-zeo delay, like |
Sadly this doesn't work entirely consistently. |
Oh it's work on Firefox but not Chrome. |
Describe the bug
When an element with a seperate
in:
andout:
transition (or just anout:
transition) is rapidly toggled in a short period (as in, hidden due to state-based{#if condition}
being briefly false, and then shown due to being true), it is incorrectly removed from the document after the intro animation finishes. If there is noin:
, the outro animation plays instead and the element is hidden, despite the{#if ...}
being true.I've run into this when attempting to handle Form Actions from SvelteKit, with something like
{#if form?.error}
. If the form is re-submitted this becomesundefined
before quickly becoming a value, casing the issue on the element presenting the error.Reproduction
A REPL which attempts to simulate the issue artificially using timeouts on state:
https://svelte-5-preview.vercel.app/#H4sIAAAAAAAACo1QwW7bMAz9FUIr0BhI6-3qOSoG7BN6m3ZwJDolIlOqRKcIDP37IDXYeusOgkTyPfG9t6mZPGY1_NoUTwuqQf2IUe2VXGMt8gW9oNqrHNZka2fMNlEUbdgILTEkgQ3mySEUmFNY4P6d00uaOJNQ4PuKrcejQIjIcIC7LJPgbp58xu674Tq-I84RrewqpjM89v928faF5kYuFTo6ukCWq8eDUcfJnk8prOwebPAhDZDQGQXEQxMWVmmPptnIGLW8UAbKIOF08jgdPYINLMgy9rHBxt7RRRveeprrRh6Pq0hgCGw92fNh23UHvd3cSFqxFF2rsX8H6k8ozXkp2vqQ8VNSlfRG7MLbY0Z5pgXDKru_IyMff62dsoev3f-yqvwb6VtnuBT9upI9--stoI_yov5Zo38Jq3dwxAGaoScwqt5GwQBGNVPOqFLjVHu1BEczoVNDS-p3-QOlBZh6eAIAAA==
Press "quickly toggle" twice to see the issue.
You can also remove
in:fade
to see how just an outro behaves.Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: