components icon indicating copy to clipboard operation
components copied to clipboard

fix(material/expansion): panel appearing as open when parent is animating away

Open crisbeto opened this issue 6 years ago • 11 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 #11765.

crisbeto avatar Jun 13 '18 18:06 crisbeto

Hi @crisbeto! This PR has merge conflicts due to recent upstream merges. Please help to unblock it by resolving these conflicts. Thanks!

ngbot[bot] avatar Sep 18 '18 21:09 ngbot[bot]

Hi @crisbeto! This PR has merge conflicts due to recent upstream merges. Please help to unblock it by resolving these conflicts. Thanks!

ngbot[bot] avatar Sep 18 '18 21:09 ngbot[bot]

Hi @crisbeto! This PR has merge conflicts due to recent upstream merges. Please help to unblock it by resolving these conflicts. Thanks!

ngbot[bot] avatar Sep 18 '18 21:09 ngbot[bot]

Hi @jelbourn @crisbeto , seems this PR hasn't been merged for a long time after being approved. For the checks, seems should rerun as a lot of them are just pending. Do you have other concerns to update? seems related to #13870

Teamop avatar Nov 28 '18 12:11 Teamop

Hi @jelbourn @crisbeto !

We're also desperately waiting for this to be merged in. All of our expansion panels are affected by this bug and it's very jarring.

stevenmcountryman avatar Nov 28 '18 16:11 stevenmcountryman

@crisbeto Been spending all afternoon playing around and trying to understand this issue.

Adding a class of .ng-animating { outline: 1px solid red; } gives me the following screenshot when animating my panel onscreen for the first time. So all the little expander icons and the panels themselves get :ng-animating which they're inheriting somehow.

image

Even if my slide animation on the 'outside' has an explicit css class and { limit: 1 } applied it still permeates into the accordion. The only way I managed to block it was by adding [@.disabled] to the accordion.`

What I'm really having a difficult time understanding is why all the controls inside accordion are able to inherit .ng-animating from the outside in the first place. If that's just the way angular works then isn't a change needed in that behavior to be able to get anywhere with fixing things like this? (and more complicated than what you said about void state?)

This is most frustrating because you think animating a panel off screen will take about 15 minutes to do and then everything exploded in my face (literally!!)

simeyla avatar Feb 20 '19 03:02 simeyla

Please Solve this Issue ASAP. Its really annoying!!!!!!

am-awais avatar May 29 '19 10:05 am-awais

Rebased and bumping to a P2, because the issue keeps getting reported.

crisbeto avatar Jan 01 '20 16:01 crisbeto

I think there is an unintended side-effect of this change. If your expansion panel starts as expanded, you see the animation occur on the page when loaded.

You can see this if you change the demo's expansion panel to be expanded, then load the page. The animation will render, when I think what we expect is that the expansion panel just initializes as open.

<mat-expansion-panel class="demo-expansion-width" #myPanel
                     expanded
                     (afterExpand)="addEvent('afterExpand')"
                     (afterCollapse)="addEvent('afterCollapse')">

  ...

</mat-expansion-panel>

andrewseguin avatar Jul 03 '20 18:07 andrewseguin

any news on that conflict?

BazylPL avatar Jul 08 '20 17:07 BazylPL

Seeing that this is still not merged I have found another workaround. When declaring the animations simply add fitting animationstates.

animations: [
	trigger( "detailExpand", [
		state( "collapsed", style( { height: "0px", minHeight: "0" } ) ),  
		state( "void", style( { height: "0px", minHeight: "0" } ) ),  
		state( "expanded", style( { height: "*" } ) ),  
		transition( "expanded <=> collapsed", animate( "225ms cubic-bezier(0.4, 0.0, 0.2, 1)" ) ),  
		transition( "expanded <=> void", animate( "225ms cubic-bezier(0.4, 0.0, 0.2, 1)" ) )  
		] )  
	]

Notice that I added a "void" state and transition.

It is duplicate code, but other than that I did not encounter any issues with it.

OlliHolli avatar Aug 08 '22 11:08 OlliHolli