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
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: animationslegacy animations package only. Otherwise use area: core.freq2: mediumtype: bug/fix
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
ngOnDestroy is called when the :leave animation starts.
Expected behavior
ngOnDestroy should be called after the :leave animation finishes.
Minimal reproduction of the problem with instructions
Wait for the :enter animation to finish. The element background is red during the whole duration of the animation.
Click the "Hide" button. The red background is removed immediately when the animation starts.
If replays are necessary, use the "Show" button to restart the reproduction.
What is the motivation / use case for changing the behavior?
If the destroy method makes visual changes to the component or directive, these will be visible during the leave animation. This results in unexpected behavior for the user.
Environment
Angular version: 4.4.6
Also reproducible in 5.0.0-rc.3
Browser:
- all
Reacted by Georgi Krustev, elclanrs, Senne Van Den Bogaert, Florian Lefevre, bchampion, Florent-Passerelle, Yohanes Oktavianus Lumentut, Hans Böse, Mikhail Khalizev, Robin and 27 more
Unfortunately we can't change this around for the current Angular. Perhaps including a new lifecycle hook in the future to handle this would be a solution.
Still an issue. My components implement a breakdown logic which I wanted to delay a bit when they are removed from ngFor, animations would work just fine for it but unfortunately ngOnDestroy is called immediately :(
I also need to do something when the component is ACTUALLY destroyed, AFTER running the animation. The hook is called "onDestroy" but actually the component is still existent when an animation is running.
Reacted by Rin Arakaki, Rado Konuch, Jaime Burgos, Andreas Turku, Ben Boyle, cfrapper, Nikita Popov, Sven Röttering, Sebastian Podgajny, John ⚒ Waw3ru and 11 more
If you are calling a reactive process (like HttpClient rest call) this process will take some time or if you are using setTimeout (microtask). If the component is destroyed before it is finished, this process will continue .... If you try to access any object or reference in the destroyed component after the process is subscribed, you will have problems. In fact, even if this subscription is HttpClient, it will not be unsubscribed. This actually show us HttpClient subscriptions should be destroyed manually even if they are destroyed automatically by Angular.
This issue was closed as obsolete due to the introduction of the new animate.enter and animate.leave APIs. The @angular/animations package is now deprecated and will be removed in Angular v23. We hope you give the new APIs a try.
angular-automatic-lock-bot commented on Sep 21, 2025
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: animationslegacy animations package only. Otherwise use area: core.freq2: mediumtype: bug/fix
Activity
Florent-Passerelle commentedon Nov 20, 2017
Same here and really annoying when using third party modules...
Otherwise we can listen to .done event :
matsko commentedon May 1, 2018
Unfortunately we can't change this around for the current Angular. Perhaps including a new lifecycle hook in the future to handle this would be a solution.
lorado commentedon Aug 1, 2018
Hello. Can you say, when do you plan to implement a solution?
The described behaviour by @gyoshev exists also in angular 6.1. I created an example on stackblitz: https://stackblitz.com/edit/angular-s1ikhg
ds-codemag commentedon Jul 17, 2019
Now is angular 8 and I still have this problem
Ploppy3 commentedon Feb 14, 2020
Is it possible to fix this with Angular 9 Ivy ?
waterplea commentedon May 4, 2020
Still an issue. My components implement a breakdown logic which I wanted to delay a bit when they are removed from ngFor, animations would work just fine for it but unfortunately ngOnDestroy is called immediately :(
charlie-lk commentedon Jul 14, 2020
This issue renders the routing animations utterly useless.
carlescs commentedon Sep 2, 2020
Is there any timeline for fixing this? We have a lot of problems with animations with DevExtreme components inside.
Angular version: 9.1.0 (Ivy)
DevExtreme: 20.1.6
2 remaining items
dmoore1181 commentedon Oct 8, 2020
I am having this issue as well within Angular 9.1.7 and DevExtreme 20.1.7. Is there any timeline on an expected fix?
dodlhuat commentedon Aug 13, 2021
We've reached Angular 12 and the issue still seems to persist. Looks like this won't be changed at all I guess.
EchopixUser commentedon Nov 8, 2021
Will this ever be fixed?? An issue of this magnitude from 2017 should've already been fixed IMO.
MickL commentedon Nov 10, 2021
I also need to do something when the component is ACTUALLY destroyed, AFTER running the animation. The hook is called "onDestroy" but actually the component is still existent when an animation is running.
Is there any workaround?
Too bad this is open since 4 years now :(
Elidor00 commentedon Dec 9, 2021
I confirm that the problem persists also in angular 12.2
grg-kvl commentedon Feb 3, 2022
The same with version 13. Very annoying.
Mikastark commentedon Mar 20, 2024
In v17.3.0, emitting with an output signals in a
(@animation.done)will throw an error :IMO, component destruction should happen after the end of the leave animation.
As temporal workaround, I wrap ouput emits with a
if (event.totalTime > 0)but I'm not sure this is really safezip-fa commentedon Apr 24, 2024
Sorry for spamming the whole team's mail boxes, but can confirm - same issue here if emitting to output or setting model signal's value
DDtMM commentedon Jun 7, 2024
I just wanted to reiterate the issue @zip-fa brought up. I am having the same issue in Angular 18.0.1.
To introduce the error, all I had to do was change the following in a "OffcanvasComponent" that emits its state as its animation changes.
To
blueiceprj commentedon Nov 21, 2024
If you are calling a reactive process (like HttpClient rest call) this process will take some time or if you are using setTimeout (microtask). If the component is destroyed before it is finished, this process will continue .... If you try to access any object or reference in the destroyed component after the process is subscribed, you will have problems. In fact, even if this subscription is HttpClient, it will not be unsubscribed. This actually show us HttpClient subscriptions should be destroyed manually even if they are destroyed automatically by Angular.
sherlock1982 commentedon Feb 26, 2025
This is really annoying after migration to output signals.
Not mentioned in the docs.
https://angular.dev/errors/NG0953 leads to 404
This looks like a warning to me. Can NG0953 be moved to extendedDiagnostics ? Or somehow disabled?
thePunderWoman commentedon Aug 21, 2025
This issue was closed as obsolete due to the introduction of the new
animate.enterandanimate.leaveAPIs. The@angular/animationspackage is now deprecated and will be removed in Angular v23. We hope you give the new APIs a try.angular-automatic-lock-bot commentedon Sep 21, 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.