Skip to content
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

feat(tabs): add animation done event #5238 #6811

Merged
merged 5 commits into from
Dec 13, 2017

Conversation

amcdnl
Copy link
Contributor

@amcdnl amcdnl commented Sep 2, 2017

Addresses #5238 by adding an animationDone event that is triggered after the tab body transition has completed.

Closes #3032

@amcdnl amcdnl self-assigned this Sep 2, 2017
@amcdnl amcdnl requested a review from jelbourn September 2, 2017 15:43
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Sep 2, 2017
@@ -269,5 +272,6 @@ export class MdTabGroup extends _MdTabGroupMixinBase implements AfterContentInit
_removeTabBodyWrapperHeight(): void {
this._tabBodyWrapperHeight = this._tabBodyWrapper.nativeElement.clientHeight;
this._renderer.setStyle(this._tabBodyWrapper.nativeElement, 'height', '');
this.animationDone.emit();
Copy link
Member

Choose a reason for hiding this comment

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

Unit test? Even with NoopAnimationModule, it should still fire the event

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like the _onTranslateTabComplete function is getting called in tab-body.ts, however, the onCentered event that is captured in tab-group.ts in the _removeTabBodyWrapperHeight method is not getting triggered in the tests. Any thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

What kind of flushing / waiting does the test use?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is the test I've written for this:

fit('should fire animation done event', async (() => {
  fixture.detectChanges();

  spyOn(fixture.componentInstance, 'animationDone');
  let tabLabel = fixture.debugElement.queryAll(By.css('.mat-tab-label'))[1];
  tabLabel.nativeElement.click();
  fixture.detectChanges();

  fixture.whenStable().then(() => {
    fixture.detectChanges();
    expect(fixture.componentInstance.animationDone).toHaveBeenCalled();
  });
}));

@amcdnl
Copy link
Contributor Author

amcdnl commented Oct 3, 2017

@jelbourn Test added :)

@jelbourn
Copy link
Member

jelbourn commented Oct 6, 2017

ERROR: /home/travis/build/angular/material2/src/lib/tabs/tab-group.spec.ts[209, 5]: Calls to 'fit' are not allowed.

@amcdnl
Copy link
Contributor Author

amcdnl commented Oct 9, 2017

@jelbourn - #facepalm - fixed.

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Oct 27, 2017
@tinayuangao
Copy link
Contributor

@amcdnl Please rebase. Thanks!

@amcdnl
Copy link
Contributor Author

amcdnl commented Dec 2, 2017

@tinayuangao - Done :)

@andrewseguin andrewseguin added the target: minor This PR is targeted for the next minor release label Dec 13, 2017
@andrewseguin andrewseguin merged commit 3a52624 into angular:master Dec 13, 2017
@amcdnl amcdnl deleted the animation-done-5238 branch December 16, 2017 21:26
@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 7, 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 target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Tabs] Add output for onCentered
5 participants