Skip to content

Commit

Permalink
fix(tabs): animation error with nested tab groups
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 angular#4277.
  • Loading branch information
crisbeto committed Apr 27, 2017
1 parent 16bba72 commit a20ad74
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 {}

0 comments on commit a20ad74

Please sign in to comment.