-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(expansion): MatExpansionHeader transition animations #13088
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
Conversation
fix MatExpansionPanel when included in a sortable MatTable See issue angular#11990 for more details. Closes angular#11990
fix MatExpansionPanel when included in a sortable MatTable See issue angular#11990 for more details. Fixes angular#11990
@chriskrolak Can you explain a bit about how this change addresses #11990? I am not quite following. |
Honestly I also have no idea how it works; I copied it from a solution somewhere online that I can't find anymore. It does fix the issue though (tested locally). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change just the one comment?
Otherwise it looks fine to commit as it should address the exact issue you are seeing, though beyond the reproduction scope I can't say for sure.
Though I will comment that this does not address the underlying problem of ViewContainer.move
calls causing the full exit, and then improper reentry of the node as far as the animation states are concerned. This is something that will have to be addressed upstream in angular/angular.
@@ -30,12 +30,12 @@ export const matExpansionAnimations: { | |||
indicatorRotate: trigger('indicatorRotate', [ | |||
state('collapsed', style({transform: 'rotate(0deg)'})), | |||
state('expanded', style({transform: 'rotate(180deg)'})), | |||
transition('expanded <=> collapsed', animate(EXPANSION_PANEL_ANIMATION_TIMING)), | |||
transition('collapsed <=> expanded', animate(EXPANSION_PANEL_ANIMATION_TIMING)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can make this * <=> *
here.
For reference purposes angular/angular#18847 looks to be the issue tracking this in angular/angular |
fix(expansion): MatExpansionPanel animations fix MatExpansionPanel when included in a sortable MatTable See issue angular#11990 for more details. Fixes angular#11990
After giving it another pass, I realized the reason that this change actually ends up being a breaking change for the current way things work. With this change, any expansion panel that starts as expanded would animate to its initial size instead of appearing immediately at the correct size. |
@@ -30,12 +30,12 @@ export const matExpansionAnimations: { | |||
indicatorRotate: trigger('indicatorRotate', [ | |||
state('collapsed', style({transform: 'rotate(0deg)'})), | |||
state('expanded', style({transform: 'rotate(180deg)'})), | |||
transition('expanded <=> collapsed', animate(EXPANSION_PANEL_ANIMATION_TIMING)), | |||
transition('* <=> *', animate(EXPANSION_PANEL_ANIMATION_TIMING)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For all of the transitions can we have it be:
void => collapsed, expanded <=> collapsed
]), | ||
|
||
/** Animation that expands and collapses the panel header height. */ | ||
expansionHeaderHeight: trigger('expansionHeight', [ | ||
state('collapsed', style({ | ||
state('collapsed, void', style({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of the states of collapsed
should be collapsed, void
@@ -30,12 +30,12 @@ export const matExpansionAnimations: { | |||
indicatorRotate: trigger('indicatorRotate', [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment around line 22, above the const
line:
/**
* A bug in angular animation's `state` when ViewContainers are moved using ViewContainerRef.move()
* causes the animation state of moved components to become `void` upon exit, and not update again
* upon reentry into the DOM. This can lead a to situation for the expansion panel where the state
* of the panel is `expanded` or `collapsed` but the animation state is `void`.
*
* To correctly handle animating to the next state, we animate between `void` and `collapsed` which
* are defined to have the same styles. Since angular animates from the current styles to the
* destination state's style definition, in situations where we are moving from `void`'s styles to
* `collapsed` this acts a noop since no style values change.
*
* In the case where angular's animation state is out of sync with the expansion panel's state, the
* expansion panel being `expanded` and angular animations being`void`, the animation from the
* `expanded`'s effective styles (though in a `void` animation state) to the collapsed state will
* occur as expected.
*
* Angular Bug: https://github.com/angular/angular/issues/18847
**/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to ask for such a large block of comment in the code your committing, I just didn't want to ask your to have to write out the explanation.
fix(expansion): MatExpansionPanel animations fix MatExpansionPanel when included in a sortable MatTable See issue angular#11990 for more details. Fixes angular#11990
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) |
CLA fixed since it was bad from my lint fix commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, Thanks!
… height Works around the expansion panel header animating on init, if its header is different from the default one. The original issue comes from the code introduced in angular#13088, but we can't remove that code, because it's there to work around a bug in Angular. Fixes angular#16067.
… height (angular#16122) Works around the expansion panel header animating on init, if its header is different from the default one. The original issue comes from the code introduced in angular#13088, but we can't remove that code, because it's there to work around a bug in Angular. Fixes angular#16067.
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. |
See issue #11990 for rationale.
No tests included - I would greatly appreciate help on how to write a unit test for this, since I can only reproduce the bug as a combination of many components.