Skip to content

ngAfterViewChecked should be fired after the end of leave animation #11393

@AbdulRahmanAlHamali

Description

@AbdulRahmanAlHamali

I'm submitting a ... (check one with "x")

[x] bug report 

Current behavior
The behaviour is demonstrated in this plunker:
https://embed.plnkr.co/tQVOfAWdrO9x0X4fE8Jz/

If you click on node1 in this plunker, the node will expand and show nodes inside of it, the colors will be correctly alternating (grey - white), but then, if you click on the node again to collapse it, the color alternation will be ruined.

The reason for this is that ngAfterViewChecked is getting called before the animation is done, and is not getting called again after the animation is done and all elements are removed correctly. In other words, ngAfterViewChecked is getting called when the elements that are supposed to have been removed, are not removed yet, and they are, thus, messing up the count for the for loop that generates the colors of the rows.
To validate that the problem only happens when there is animation, you could remove the animation from the ul, and see how the coloring is done correctly.

Expected/desired behavior

ngAfterViewChecked is called after the animation is done and the elements have been removed, which will result in the colors being correct.

Reproduction of the problem
Here's the plunker again:
https://embed.plnkr.co/tQVOfAWdrO9x0X4fE8Jz/

What is the expected behavior?
To get a call for ngAfterViewChecked (or at least to some lifecycle hook), after the animation is done and the elements are fully removed.

What is the motivation / use case for changing the behavior?
Executing code after elements that are animated using the (* => void) transition have been fully removed.

Please tell us about your environment:

  • Angular version: 2.0.0-rc.6
  • Browser: Chrome (tried on more than one version)
  • Language: all (not really related to the language)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions