You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
animate.enter on new item and animate.leave on existing item don't trigger at the same time in @for #63307
No obvious error other than animation not working as expected.
Please provide the environment you discovered this bug in (run ng version)
All latest 20.2
Anything else?
In my own projects, which are still using platformBrowser().bootstrapModule(...) I notice that having BrowserAnimationsModule fixes this problem. I fount out about this because BrowserAnimationsModule is now deprecated and I wanted to remove it sooner rather than later. I ran into this bug while trying to use the new seemingly obvious feature. Simply adding it back makes both enter and leave animations work as expected.
I also tried adding BrowserAnimationsModule in the stackblitz example, to prove my point, but it error-ed. I don't know how to fix the error, I will have to leave it in as a comment.
changed the title [-]`animate.enter` on new item and `animate.leave` on existing item don't trigger at the same time[/-][+]`animate.enter` on new item and `animate.leave` on existing item don't trigger at the same time in `@for`[/+]on Aug 21, 2025
OK so I can see what's happening here. We have some code that prevents duplicate nodes from showing up when nodes are toggled quickly. It cancels and removes the leave animation so that the enter one can fire safely without layout shift. In this case, because the remove and add to the for loop are happening in the same CD, that protection is cancelling the animation on the leaving node.
We'll see if there's a fix that can keep the duplicate node prevention while allowing leave animations to fire in situations like this.
I’ve been struggling with this issue all the morning and was about to file a bug report, but then I found this thread. Hopefully, it will be resolved soon.
I can also confirm that it works as expected when using the @angular/animations package.
My current workaround is to create wrapper and keep enter and leave animations on separate elements, but it looks ugly, requires additional elements and comments why it was made to look so ugly.
Cheers @thePunderWoman . A quick off topic Q, do we plan to have any replacements for staggering animations? Or should we use third party animation libraries?
I’ve upgraded my project to version 20.2.1, but it still doesn’t work for me.
I also forked @princemaple’s StackBlitz here: link
. Unfortunately, it doesn’t work either. Interestingly, when I experimented with the dependencies earlier, it did work at some point.
Could you please help me understand what I might be doing wrong?
Huh I don't know why it still doesn't work in this mini repro, it's been working for my own project after the upgrade, FYI. I've completed removed animations package and BrowserAnimationsModule.
Activity
[-]`animate.enter` on new item and `animate.leave` on existing item don't trigger at the same time[/-][+]`animate.enter` on new item and `animate.leave` on existing item don't trigger at the same time in `@for`[/+]thePunderWoman commentedon Aug 21, 2025
OK so I can see what's happening here. We have some code that prevents duplicate nodes from showing up when nodes are toggled quickly. It cancels and removes the leave animation so that the enter one can fire safely without layout shift. In this case, because the remove and add to the for loop are happening in the same CD, that protection is cancelling the animation on the leaving node.
We'll see if there's a fix that can keep the duplicate node prevention while allowing leave animations to fire in situations like this.
princemaple commentedon Aug 21, 2025
So BrowserAnimationModule somehow making it work was a miracle in my project? 😉
Or it broke the duplication prevention somehow
thePunderWoman commentedon Aug 21, 2025
It could be. the Animations Module uses a custom renderer. So it could have been doing something there.
fix(core): Ensures `@for` loop animations never get cancelled
fix(core): Ensures `@for` loop animations never get cancelled
fix(core): Ensures `@for` loop animations never get cancelled
fix(core): Ensures `@for` loop animations never get cancelled
fix(core): Ensures `@for` loop animations never get cancelled
fix(core): Ensures `@for` loop animations never get cancelled
fix(core): Ensures `@for` loop animations never get cancelled
fix(core): Ensures `@for` loop animations never get cancelled (#63328)
fix(core): Ensures `@for` loop animations never get cancelled (angula…
ahimik commentedon Aug 25, 2025
I’ve been struggling with this issue all the morning and was about to file a bug report, but then I found this thread. Hopefully, it will be resolved soon.
I can also confirm that it works as expected when using the @angular/animations package.
My current workaround is to create wrapper and keep enter and leave animations on separate elements, but it looks ugly, requires additional elements and comments why it was made to look so ugly.
thePunderWoman commentedon Aug 25, 2025
@princemaple @ahimik This should get released with the patch on Wednesday this week. Once that goes out, you should be all set.
princemaple commentedon Aug 25, 2025
Cheers @thePunderWoman . A quick off topic Q, do we plan to have any replacements for staggering animations? Or should we use third party animation libraries?
thePunderWoman commentedon Aug 25, 2025
@princemaple This is accomplishable using CSS. We have an example on the migration guide: https://angular.dev/guide/animations/migration#with-native-css-7
princemaple commentedon Aug 25, 2025
Thanks!
ahimik commentedon Aug 29, 2025
Hi @thePunderWoman ,
I’ve upgraded my project to version 20.2.1, but it still doesn’t work for me.
I also forked @princemaple’s StackBlitz here: link
. Unfortunately, it doesn’t work either. Interestingly, when I experimented with the dependencies earlier, it did work at some point.
Could you please help me understand what I might be doing wrong?
Thanks in advance!
princemaple commentedon Aug 29, 2025
Huh I don't know why it still doesn't work in this mini repro, it's been working for my own project after the upgrade, FYI. I've completed removed animations package and BrowserAnimationsModule.
thePunderWoman commentedon Aug 29, 2025
@ahimik You'd want to update to 20.2.2. That's the patch that went out on Wednesday.
And I can confirm that updating the repro link to that version results in it working. :D
ahimik commentedon Aug 29, 2025
@thePunderWoman , sorry. Got confused about versions. Works like a charm now, thank You!
angular-automatic-lock-bot commentedon Sep 29, 2025
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.