Skip to content

Two elements appear when leave animation is running and @if is toggled true #63020

Closed

Description

@thePunderWoman

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

core

Is this a regression?

No

Description

In the case where you use an animate.enter and an animate.leave with a longer animation time you can see a duplicated element in the case that you toggle the @if to true while the leave animation is running. While this is expected, ideally we should not see duplicated elements.

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw


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


Anything else?

No response

Activity

  1. added
    area: core
    core: animations
    on Aug 6, 2025
  2. modified the milestone: needsTriage on Aug 6, 2025
  3. thePunderWoman commented on Aug 6, 2025

    @thePunderWoman
    ContributorAuthor

    The biggest challenge here is that while the leave animation is running, the element is technically destroyed and Angular only can create a new element at this point. Ideally we could cancel / complete the running animations and remove the node right away in this situation, but we'd have to know which element to remove.

  4. kbrilla commented on Aug 6, 2025

    @kbrilla
    Contributor

    Well in native css world with :starting-style and :exit-style I would expect to see duplicated elements as well, so mayby it's not unexpected at all?

    Another way I see it, would be to reuse dom node that are sheduled to be destroyed afrer animation ends? But that would probably lead to changes in ivy?

  5. thePunderWoman commented on Aug 6, 2025

    @thePunderWoman
    ContributorAuthor

    @kbrilla yeah, that's totally expected, but it's just not ideal. We definitely wouldn't re-use the DOM node at this point. We should be able to identify the exiting DOM node though and be able to remove it immediately in the case that an enter is about to happen.

  6. added 5 commits that reference this issue on Aug 7, 2025
    7bf5654
    db67824
    4d04ff0
    a374dac
    4146c43
  7. added a commit that references this issue on Aug 8, 2025
    6a11846
  8. angular-automatic-lock-bot commented on Sep 8, 2025

    @angular-automatic-lock-bot

    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.

  9. locked and limited conversation to collaborators on Sep 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area: corecore: animations

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions