Skip to content

In some cases, the animate.leave animations leave a component in the DOM. #67400

@basrieter

Description

@basrieter

Which @angular/* package(s) are the source of the bug?

animations

Is this a regression?

Yes

Description

With Angular 21.2.0 it seems that something broke with the CSS animations. To make thinks simple I created a directive to add animations to html elements. This directive uses animate.leave.

Starting from version 21.2.0, it seems that components are not removed after they animate on "leave" when routing away from an component. See the stackblitz below. It mini project has 2 routes with components. And 2 links that switch between the two routes.

I think it is related to #67032

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/stackblitz-starters-htmhdsyu

If you click on first, then second, you will notice that the new component showing "TEST" appears, but the old component (green square) stays and is not removed from the DOM.

Clicking on first again, will show another (duplicate) component (green square).

Please provide the exception or error you saw

Components not being removed.

Please provide the environment you discovered this bug in (run ng version)

Angular CLI       : 21.2.0
Angular           : 21.2.0
Node.js           : 24.13.0
Package Manager   : npm 11.6.2
Operating System  : win32 x64

┌───────────────────────────────────┬───────────────────┬───────────────────┐
│ Package                           │ Installed Version │ Requested Version │
├───────────────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build                    │ 21.2.0            │ ^21.2.0           │
│ @angular/cli                      │ 21.2.0            │ ^21.2.0           │
│ @angular/common                   │ 21.2.0            │ ^21.2.0           │
│ @angular/compiler                 │ 21.2.0            │ ^21.2.0           │
│ @angular/compiler-cli             │ 21.2.0            │ ^21.2.0           │
│ @angular/core                     │ 21.2.0            │ ^21.2.0           │
│ @angular/forms                    │ 21.2.0            │ ^21.2.0           │
│ @angular/localize                 │ 21.2.0            │ ^21.2.0           │
│ @angular/platform-browser         │ 21.2.0            │ ^21.2.0           │
│ @angular/platform-browser-dynamic │ 21.2.0            │ ^21.2.0           │
│ @angular/router                   │ 21.2.0            │ ^21.2.0           │
│ @angular/service-worker           │ 21.2.0            │ ^21.2.0           │
│ rxjs                              │ 7.8.2             │ ^7.8.2            │
│ typescript                        │ 5.9.3             │ ~5.9.3            │
│ zone.js                           │ 0.15.1            │ ~0.15.1           │
└───────────────────────────────────┴───────────────────┴───────────────────┘

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreIssues related to the framework runtimecore: animationsIssues related to `animate.enter` and `animate.leave`state: has PR

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions