-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mat-expansion-panel "opens" with angular enter-leave animations, although current state is closed. #11765
Comments
Fixes an issue where the expansion panel will appear as if it is open, if the element is part of a component that is animating away. The issue comes from the fact that Angular resets the animation state to `void` which we don't have in the animation definitions. Fixes angular#11765.
Fixes an issue where the expansion panel will appear as if it is open, if the element is part of a component that is animating away. The issue comes from the fact that Angular resets the animation state to `void` which we don't have in the animation definitions. Fixes angular#11765.
Fixes an issue where the expansion panel will appear as if it is open, if the element is part of a component that is animating away. The issue comes from the fact that Angular resets the animation state to `void` which we don't have in the animation definitions. Fixes #11765.
Fixes an issue where the expansion panel will appear as if it is open, if the element is part of a component that is animating away. The issue comes from the fact that Angular resets the animation state to `void` which we don't have in the animation definitions. Fixes #11765.
Fixes an issue where the expansion panel will appear as if it is open, if the element is part of a component that is animating away. The issue comes from the fact that Angular resets the animation state to `void` which we don't have in the animation definitions. Fixes angular#11765.
Fixes an issue where the expansion panel will appear as if it is open, if the element is part of a component that is animating away. The issue comes from the fact that Angular resets the animation state to `void` which we don't have in the animation definitions. Fixes angular#11765.
Fixes an issue where the expansion panel will appear as if it is open, if the element is part of a component that is animating away. The issue comes from the fact that Angular resets the animation state to `void` which we don't have in the animation definitions. Fixes #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. |
I have created an example for a router transition which illustrates the same problem: |
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. |
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. |
Can you please tell how you fixed it? I partially fixed it in my code by to putting the content of expansion-panel to ng-template and fortunately it helped with collapsing it during transition animation, but instead that behavior, now initial size of expansion-panel is smaller then it should be (i believe because it contains totally nothing), but after animation it became normal. |
I happen to only have this problem when a custom component, that contains a
The expansion panel header, in its closed state, is normally 48px. If you don't force it to this height during the animation, but try to remove the expansion panel content DIV by settings its height to 0, it renders at the height of its content instead (the panel-title element, probably) then jumps to the 48px height after the animation completes. Hope this helps! |
With little changes it works, thanks) |
I think for your second rule you'd need a piercing selector, e.g. |
Piercing selector helped a lot:
To say the truth, I totally forgot that styles are encapsulated by default in components not only from child to parent but also in opposite way. Thanks) |
Fixes an issue where the expansion panel will appear as if it is open, if the element is part of a component that is animating away. The issue comes from the fact that Angular resets the animation state to `void` which we don't have in the animation definitions. Fixes angular#11765.
Hi every body, have you got some news about this issue ? Do you know if this fix will be integrated soon ? Thanks a lot! |
I solved it temporarily until a fix arrives via a global style in style.scss:
|
So are Angular animations fundamentally broken if we get issues like this? To visualize at least what's going on I found it helpful to add the following to global styles:
During a simple slide-in animation, the view of my accordion is like this: So the I've concluded the only way to get on with my day right now - is to just disable animations completely on the accordion.
None of the css solutions worked for me. The problem being they won't work for animating an accordion offscreen when you quite likely do want the panel to remain open in its current state. In addition if I click on an accordion that initially animates on screen (with a 30s animation) then I can't open any panels once the animation is complete. That seems like a much more serious issue, which I don't even understand. In any case the problem seems to be that the If there's no way to prevent this then surely animations are broken, and the fix needs to be of broader scope than a nasty css hack? |
it solves the problem but it causes mat-panel content to jump for a while :( |
Finally solved this by using these attributes you can change the height as per requirement TY me LATER :) ;) ;p |
I was able to implement it with your approach of disabling animations instead this css's workarounds, but added a little twist , I instead setting the animations fully off I binded that field
And on my html Just make sure to turn disableAnimations to true when this accordion leaves the screen so it fixes the next time the mat-expansion-panel shows on the screen, for me this accordion is inside a mat dialog so i achieved this with the afterClosed event |
Fixes an issue where the expansion panel will appear as if it is open, if the element is part of a component that is animating away. The issue comes from the fact that Angular resets the animation state to `void` which we don't have in the animation definitions. Fixes angular#11765.
Fixes an issue where the expansion panel will appear as if it is open, if the element is part of a component that is animating away. The issue comes from the fact that Angular resets the animation state to `void` which we don't have in the animation definitions. Fixes #11765.
Having this issue when expansion panel is used in a mat-dialog. Expands for a second when dialog is opened. |
any updates? |
The only workaround that worked for me is: <mat-accordion [@.disabled]="true"> Thanks @chipicow |
@ALGDB Angular will throw you the error A possible solution is to queue the operation to the next change detection check like this: ngAfterViewChecked(): void {
setTimeout(() => {
this.disableAnimations = false;
}, 0)
} A more detailed explanation and different solutions can be found here in this video from the Angular docs. |
…ting away Fixes an issue where the expansion panel will appear as if it is open, if the element is part of a component that is animating away. The issue comes from the fact that Angular resets the animation state to `void` which we don't have in the animation definitions. Fixes angular#11765.
I solved only this
|
I've found another workaround that might help a few people. |
I have also fixed using:
|
similar to above, works for me:
|
TL;DRChanging
to
fixed my issues. Also ran into this issue today, and stumbled into a solution that seems to fix my issues. My SetupDependencies:
Two router animations
All components use IssueFor both situations the expansion panel starts as expanded, the page fades/slides in, then a moment later the expansion panel closes. ResearchI tried some of the solutions given above, with 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. This is obviously undesired, but even more concerning is this doesn't match my expectations, as I have an transition('* => *', [
// Prep for animation
group([
query(':enter', style(...), { optional: true }),
query(':leave', style(...), { optional: true }),
]),
// Slide in
group([
query(':enter', animate(...), { optional: true }),
query(':leave', animate(...), { optional: true }),
]),
// Animate children
query(':enter', animateChild(), { optional: true }),
]); 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 Stumbling into a solutionWhat stood out to me at this point was the So, is there a way I can target all descendants? `query(":animating")` : Query all currently animating elements.
`query("@*")` : Query all elements that contain an animation triggers. I tried with Working SolutionIn the end my animation sequence ended up being transition('* => *', [
// Prep for animation
group([
query(':enter', style(...), { optional: true }),
query(':leave', style(...), { optional: true }),
]),
// Slide in
group([
query(':enter', animate(...), { optional: true }),
query(':leave', animate(...), { optional: true }),
]),
// Animate :enter descendants
query(':enter', query('@*', animateChild(), { optional: true }), { optional: true }),
]); I think I still had the Final ThoughtsWhile 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 My remaining unanswered questions are
|
Reworks the expansion panel to animate purely with CSS, rather than going through the `@angular/animations` module. This simplifies the setup and allows us to resolve several long-standing bug reports. Fixes angular#27946. Fixes angular#22715. Fixes angular#21434. Fixes angular#20610. Fixes angular#20517. Fixes angular#17177. Fixes angular#16534. Fixes angular#16503. Fixes angular#14952. Fixes angular#14759. Fixes angular#14075. Fixes angular#11765.
Reworks the expansion panel to animate purely with CSS, rather than going through the `@angular/animations` module. This simplifies the setup and allows us to resolve several long-standing bug reports. Fixes angular#27946. Fixes angular#22715. Fixes angular#21434. Fixes angular#20517. Fixes angular#17177. Fixes angular#16534. Fixes angular#16503. Fixes angular#14952. Fixes angular#14759. Fixes angular#14075. Fixes angular#11765.
Reworks the expansion panel to animate purely with CSS, rather than going through the `@angular/animations` module. This simplifies the setup and allows us to resolve several long-standing bug reports. Fixes #27946. Fixes #22715. Fixes #21434. Fixes #20517. Fixes #17177. Fixes #16534. Fixes #16503. Fixes #14952. Fixes #14759. Fixes #14075. Fixes #11765. (cherry picked from commit aafa151)
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug, feature request, or proposal:
Bug
What is the expected behavior?
Mat-expansion-panel, when animating in or out, will stay in current state of opened or closed and render as such.
What is the current behavior?
mat-expansion-panel, when animating out, will open and display all hidden panel content, while still showing the current state as closed.
What are the steps to reproduce?
https://stackblitz.com/edit/angular-ykxmcr?file=src%2Fapp%2Fhero-list-multistep.component.ts
What is the use-case or motivation for changing an existing behavior?
Keeping the panel closed when animating out provides a much cleaner experience for the UI by preventing jumpiness and inconsistencies.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
@angular/core 6.0.4
@angular/material 6.2.1
@angular/cdk 6.2.1
Chrome 67.0.3396.79
Firefox 60.0.2
Safari 11.1
Is there anything else we should know?
This happens with all animations I have tested, not just the one provided in the stackblitz example.
The text was updated successfully, but these errors were encountered: