Skip to content

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

Merged
merged 5 commits into from
Sep 18, 2018

Conversation

chriskrolak
Copy link
Contributor

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.

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
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Sep 12, 2018
@jelbourn jelbourn added G This is is related to a Google internal issue P2 The issue is important to a large percentage of users, with a workaround labels Sep 12, 2018
@josephperrott
Copy link
Member

@chriskrolak Can you explain a bit about how this change addresses #11990? I am not quite following.

@chriskrolak
Copy link
Contributor Author

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).

Copy link
Member

@josephperrott josephperrott left a 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)),
Copy link
Member

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.

@josephperrott
Copy link
Member

For reference purposes angular/angular#18847 looks to be the issue tracking this in angular/angular

@josephperrott josephperrott added the target: patch This PR is targeted for the next patch release label Sep 13, 2018
@josephperrott josephperrott changed the title Fix MatExpansionHeader transition animations. fix(expansion): MatExpansionHeader transition animations Sep 13, 2018
fix(expansion): MatExpansionPanel animations

fix MatExpansionPanel when included in a sortable MatTable
See issue angular#11990 for more details.

Fixes angular#11990
@josephperrott
Copy link
Member

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)),
Copy link
Member

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({
Copy link
Member

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', [
Copy link
Member

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
 **/

Copy link
Member

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.

chriskrolak and others added 2 commits September 13, 2018 18:12
fix(expansion): MatExpansionPanel animations

fix MatExpansionPanel when included in a sortable MatTable
See issue angular#11990 for more details.

Fixes angular#11990
@googlebot
Copy link

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 cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

@googlebot googlebot added cla: no PR author must sign Google's Contributor License Agreement: https://opensource.google.com/docs/cla and removed cla: yes PR author has agreed to Google's Contributor License Agreement labels Sep 14, 2018
@josephperrott josephperrott added cla: yes PR author has agreed to Google's Contributor License Agreement and removed cla: no PR author must sign Google's Contributor License Agreement: https://opensource.google.com/docs/cla labels Sep 14, 2018
@googlebot
Copy link

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.)

@josephperrott
Copy link
Member

CLA fixed since it was bad from my lint fix commit.

Copy link
Member

@josephperrott josephperrott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks!

@josephperrott josephperrott added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Sep 14, 2018
@mmalerba mmalerba merged commit 4a96539 into angular:master Sep 18, 2018
crisbeto added a commit to crisbeto/material2 that referenced this pull request May 26, 2019
… 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.
jelbourn pushed a commit that referenced this pull request Jun 19, 2019
… height (#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 #13088, but we can't remove that code, because it's there to work around a bug in Angular.

Fixes #16067.
RudolfFrederiksen pushed a commit to RudolfFrederiksen/material2 that referenced this pull request Jun 21, 2019
… 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.
andrewseguin pushed a commit that referenced this pull request Jul 2, 2019
… height (#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 #13088, but we can't remove that code, because it's there to work around a bug in Angular.

Fixes #16067.
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement G This is is related to a Google internal issue P2 The issue is important to a large percentage of users, with a workaround target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants