Skip to content

Commit 1766649

Browse files
crisbetommalerba
authored andcommitted
fix(tabs): animation error with nested tab groups (#4315)
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.
1 parent c94f471 commit 1766649

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

src/lib/tabs/tab-body.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export type MdTabBodyOriginState = 'left' | 'right';
5555
},
5656
animations: [
5757
trigger('translateTab', [
58+
state('void', style({transform: 'translate3d(0, 0, 0)'})),
5859
state('left', style({transform: 'translate3d(-100%, 0, 0)'})),
5960
state('left-origin-center', style({transform: 'translate3d(0, 0, 0)'})),
6061
state('right-origin-center', style({transform: 'translate3d(0, 0, 0)'})),

src/lib/tabs/tab-group.spec.ts

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
} from '@angular/core/testing';
44
import {MdTabGroup, MdTabsModule, MdTabHeaderPosition} from './index';
55
import {Component, ViewChild} from '@angular/core';
6-
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
6+
import {NoopAnimationsModule, BrowserAnimationsModule} from '@angular/platform-browser/animations';
77
import {By} from '@angular/platform-browser';
88
import {Observable} from 'rxjs/Observable';
99
import {MdTab} from './tab';
@@ -290,6 +290,26 @@ describe('MdTabGroup', () => {
290290
}
291291
});
292292

293+
294+
describe('nested MdTabGroup with enabled animations', () => {
295+
beforeEach(async(() => {
296+
TestBed.configureTestingModule({
297+
imports: [MdTabsModule.forRoot(), BrowserAnimationsModule],
298+
declarations: [NestedTabs]
299+
});
300+
301+
TestBed.compileComponents();
302+
}));
303+
304+
it('should not throw when creating a component with nested tab groups', async(() => {
305+
expect(() => {
306+
let fixture = TestBed.createComponent(NestedTabs);
307+
fixture.detectChanges();
308+
}).not.toThrow();
309+
}));
310+
});
311+
312+
293313
@Component({
294314
template: `
295315
<md-tab-group class="tab-group"
@@ -443,3 +463,22 @@ class TabGroupWithSimpleApi {
443463
otherContent = 'Apples, grapes';
444464
@ViewChild('legumes') legumes: any;
445465
}
466+
467+
468+
@Component({
469+
selector: 'nested-tabs',
470+
template: `
471+
<md-tab-group>
472+
<md-tab label="One">Tab one content</md-tab>
473+
<md-tab label="Two">
474+
Tab two content
475+
<md-tab-group [dynamicHeight]="true">
476+
<md-tab label="Inner tab one">Inner content one</md-tab>
477+
<md-tab label="Inner tab two">Inner content two</md-tab>
478+
</md-tab-group>
479+
</md-tab>
480+
</md-tab-group>
481+
`,
482+
})
483+
class NestedTabs {}
484+

0 commit comments

Comments
 (0)