Skip to content

Commit

Permalink
fix(tabs): animation error with nested tab groups (#4315)
Browse files Browse the repository at this point in the history
Fixes an animation error that gets thrown when nesting tab groups. It appears to be due to the animation not having a defined "from" style when going from `void` to something else.

Fixes #4277.
  • Loading branch information
crisbeto authored and mmalerba committed Apr 28, 2017
1 parent c94f471 commit 1766649
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/lib/tabs/tab-body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export type MdTabBodyOriginState = 'left' | 'right';
},
animations: [
trigger('translateTab', [
state('void', style({transform: 'translate3d(0, 0, 0)'})),
state('left', style({transform: 'translate3d(-100%, 0, 0)'})),
state('left-origin-center', style({transform: 'translate3d(0, 0, 0)'})),
state('right-origin-center', style({transform: 'translate3d(0, 0, 0)'})),
Expand Down
41 changes: 40 additions & 1 deletion src/lib/tabs/tab-group.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
} from '@angular/core/testing';
import {MdTabGroup, MdTabsModule, MdTabHeaderPosition} from './index';
import {Component, ViewChild} from '@angular/core';
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
import {NoopAnimationsModule, BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {By} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable';
import {MdTab} from './tab';
Expand Down Expand Up @@ -290,6 +290,26 @@ describe('MdTabGroup', () => {
}
});


describe('nested MdTabGroup with enabled animations', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [MdTabsModule.forRoot(), BrowserAnimationsModule],
declarations: [NestedTabs]
});

TestBed.compileComponents();
}));

it('should not throw when creating a component with nested tab groups', async(() => {
expect(() => {
let fixture = TestBed.createComponent(NestedTabs);
fixture.detectChanges();
}).not.toThrow();
}));
});


@Component({
template: `
<md-tab-group class="tab-group"
Expand Down Expand Up @@ -443,3 +463,22 @@ class TabGroupWithSimpleApi {
otherContent = 'Apples, grapes';
@ViewChild('legumes') legumes: any;
}


@Component({
selector: 'nested-tabs',
template: `
<md-tab-group>
<md-tab label="One">Tab one content</md-tab>
<md-tab label="Two">
Tab two content
<md-tab-group [dynamicHeight]="true">
<md-tab label="Inner tab one">Inner content one</md-tab>
<md-tab label="Inner tab two">Inner content two</md-tab>
</md-tab-group>
</md-tab>
</md-tab-group>
`,
})
class NestedTabs {}

1 comment on commit 1766649

@alexciesielski
Copy link

Choose a reason for hiding this comment

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

Can the tests for this commit be restarted?
I'm waiting for this commit to show up in material2-builds, so I can hotfix my app.
I saw it errored due to some forRoot missing, which has been fixed (the commit already appeared in material2-builds).

Please sign in to comment.