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
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/lib/tabs/tab-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ export class MdTabGroup extends _MdTabGroupMixinBase implements AfterContentInit
/** Event emitted when focus has changed within a tab group. */
@Output() focusChange: EventEmitter<MdTabChangeEvent> = new EventEmitter<MdTabChangeEvent>();

/** Event emitted when the body animation has completed */
@Output() animationDone: EventEmitter<void> = new EventEmitter<void>();

/** Event emitted when the tab selection has changed. */
@Output() selectChange: EventEmitter<MdTabChangeEvent> = new EventEmitter<MdTabChangeEvent>(true);

Expand Down Expand Up @@ -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();
  });
}));

}
}