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
{{ message }}
Repository navigation
mat-expansion-panel "opens" with angular enter-leave animations, although current state is closed. #11765
Possibly related... I'm seeing something similar where the expansion panel is visible in a dialog as the dialog animates open. So it may appear that the animation does not have to applied directly to the expansion panel to see this behavior.
Reacted by Tai, Karam Hijazi, Patrick Michalina, Simon Weaver, Jiří Doubravský , Felix Lemke, Ecliptic Rick, Artyom Krasnyuk, Eugene Kalashnikov, mkarras and 7 more
Any updates on this? I thought maybe I had to specify something in my transition animations to cause everything to trigger in the right order, but if that's the case, I can't figure out what. I'd like to see an example of transitions that don't cause this behavior, if anybody has it working.
Possibly related... I'm seeing something similar where the expansion panel is visible in a dialog as the dialog animates open. So it may appear that the animation does not have to applied directly to the expansion panel to see this behavior.
See #13870. I am not sure they are related either, but what you describe seems similar to that issue.
That sounds likely, yeah. For now I have a workaround in my global styles. I'll keep an eye out for the linked patch landing and see if that fixes things.
Slide/Swipe when navigating from any page to any other page.
<mat-expansion-panel [expanded]="false" on the target page.
All components use OnPush change detection.
Issue
For both situations the expansion panel starts as expanded, the page fades/slides in, then a moment later the expansion panel closes.
I also sometimes have to click the header twice to get the panel to expand.
Research
I tried some of the solutions given above, with [@.disabled]="true" being the simplest fix for me, but I was left unsatisfied as it all felt like work-arounds for whatever the root problems was, and I was hoping for a solution that only changed the animation sequence/config.
After spending some time debugging in and out of the animation code and the components, I came to the conclusion that Angular wasn't animating the components on-page until some time after the router animation had finished.
In other words the animation triggers were not getting triggered until the page was done animating and what appeared to be a new change detection cycle had started.
This is obviously undesired, but even more concerning is this doesn't match my expectations, as I have an animateChild() query at the very end of my sequence that I expected to link up the child animations with the route animation.
I admit I know very little about Angular animations, this is the first project I have used them, so I thought if I moved the animateChild() higher up in the sequence it would do all the on-page animations first, then slide the page in.
However, no matter where I put the animateChild() the results were the same. Even if it was the first element in the sequence, the animations on-page always ran some time after the route animation had finished.
Stumbling into a solution
What stood out to me at this point was the Child of animateChild(), I had assumed that it animated all descendants not just direct children. Maybe that was a bad assumption?
I didn't find anything like animateChildRecursive() or animateDescendants().
So, is there a way I can target all descendants?
A quick read of the query function, I spotted some potential candidates
`query(":animating")` : Query all currently animating elements.
`query("@*")` : Query all elements that contain an animation triggers.
I tried with query(":animating") and got the same results as before, so I tried query("@*") and unexpectedly everything worked!
I thinkquery(':enter', query('@*' is targeting all descendants of the page entering and animating them.
I still had the .ng-animating red border @simeyla suggested from before, and with the fix, the expansion panel no longer has a red border while the page is sliding in.
Final Thoughts
While this did fix all the issues I was having, I still don't fully understand why it fixed them. It seems like Angular was not animating the full descendant tree with animateChild() and I don't know if that was my fault or just a bad expectation.
I hope this helps someone else having similar issues, but I will say I don't know the full scope of the @* selector so it is entirely possible this will trigger animations deep in the page undesirably.
My remaining unanswered questions are
Why query(':enter', animateChild() doesn't seem to make it all the way down to the elements on the page.
I assume this is a failure of my understanding of Angular animations, and I have a broken "chain" of animation links
Why does placing query(':enter', query('@*' as the last step in the route animation fix the problem?
I would have expected that placing it at the end would yield the same results, but no, the expansion panel is collapsed before the route animation slides the page over.
Activity
fix(expansion): panel appearing as open when parent is animating away
fix(expansion): panel appearing as open when parent is animating away
fix(expansion): panel appearing as open when parent is animating away
fix(expansion): panel appearing as open when parent is animating away
fix(expansion): panel appearing as open when parent is animating away
fix(expansion): panel appearing as open when parent is animating away
fix(expansion): panel appearing as open when parent is animating away
aeslinger0 commentedon Nov 8, 2018
Possibly related... I'm seeing something similar where the expansion panel is visible in a dialog as the dialog animates open. So it may appear that the animation does not have to applied directly to the expansion panel to see this behavior.
kiwikern commentedon Nov 11, 2018
I have created an example for a router transition which illustrates the same problem:
https://stackblitz.com/edit/angular-expansion-panel-with-route-transition-animation?file=app%2Fapp%2Fapp.component.html
thw0rted commentedon Nov 25, 2018
Any updates on this? I thought maybe I had to specify something in my transition animations to cause everything to trigger in the right order, but if that's the case, I can't figure out what. I'd like to see an example of transitions that don't cause this behavior, if anybody has it working.
virtuoushub commentedon Nov 28, 2018
@aeslinger0
See #13870. I am not sure they are related either, but what you describe seems similar to that issue.
thw0rted commentedon Nov 29, 2018
That sounds likely, yeah. For now I have a workaround in my global styles. I'll keep an eye out for the linked patch landing and see if that fixes things.
25 remaining items
OlliHolli commentedon Aug 8, 2022
I've found another workaround that might help a few people.
See my comment here.
antoci-alin commentedon Feb 22, 2023
I have also fixed using:
Vestelth commentedon Oct 20, 2023
similar to above, works for me:
Nividica commentedon Oct 30, 2023
TL;DR
Changing
query(':enter', animateChild(), { optional: true })to
query(':enter', query('@*', animateChild(), { optional: true }), { optional: true })fixed my issues.
Also ran into this issue today, and stumbled into a solution that seems to fix my issues.
My Setup
Dependencies:
Two router animations
<mat-expansion-panel [expanded]="false"on the target page.All components use
OnPushchange detection.Issue
For both situations the expansion panel starts as expanded, the page fades/slides in, then a moment later the expansion panel closes.
I also sometimes have to click the header twice to get the panel to expand.
Research
I tried some of the solutions given above, with
[@.disabled]="true"being the simplest fix for me, but I was left unsatisfied as it all felt like work-arounds for whatever the root problems was, and I was hoping for a solution that only changed the animation sequence/config.After spending some time debugging in and out of the animation code and the components, I came to the conclusion that Angular wasn't animating the components on-page until some time after the router animation had finished.
In other words the animation triggers were not getting triggered until the page was done animating and what appeared to be a new change detection cycle had started.
This is obviously undesired, but even more concerning is this doesn't match my expectations, as I have an
animateChild()query at the very end of my sequence that I expected to link up the child animations with the route animation.I admit I know very little about Angular animations, this is the first project I have used them, so I thought if I moved the
animateChild()higher up in the sequence it would do all the on-page animations first, then slide the page in.However, no matter where I put the
animateChild()the results were the same. Even if it was the first element in the sequence, the animations on-page always ran some time after the route animation had finished.Stumbling into a solution
What stood out to me at this point was the
ChildofanimateChild(), I had assumed that it animated all descendants not just direct children. Maybe that was a bad assumption?I didn't find anything like
animateChildRecursive()oranimateDescendants().So, is there a way I can target all descendants?
A quick read of the
queryfunction, I spotted some potential candidatesI tried with
query(":animating")and got the same results as before, so I triedquery("@*")and unexpectedly everything worked!Working Solution
In the end my animation sequence ended up being
I think
query(':enter', query('@*'is targeting all descendants of the page entering and animating them.I still had the
.ng-animatingred border @simeyla suggested from before, and with the fix, the expansion panel no longer has a red border while the page is sliding in.Final Thoughts
While this did fix all the issues I was having, I still don't fully understand why it fixed them. It seems like Angular was not animating the full descendant tree with
animateChild()and I don't know if that was my fault or just a bad expectation.I hope this helps someone else having similar issues, but I will say I don't know the full scope of the
@*selector so it is entirely possible this will trigger animations deep in the page undesirably.My remaining unanswered questions are
query(':enter', animateChild()doesn't seem to make it all the way down to the elements on the page.query(':enter', query('@*'as the last step in the route animation fix the problem?fix(material/expansion): switch away from animations module
fix(material/expansion): switch away from animations module
fix(material/expansion): switch away from animations module (#30119)
fix(material/expansion): switch away from animations module (angular#…
angular-automatic-lock-bot commentedon Jan 5, 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.