Skip to content

Leave animation triggers child ngOnDestroy immediately #19826

@gyoshev

Description

@gyoshev

I'm submitting a...


[ ] 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

Reproduction plunkr

  1. Wait for the :enter animation to finish. The element background is red during the whole duration of the animation.
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: animationsfreq2: mediumtype: bug/fix

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions