Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
28 changes: 28 additions & 0 deletions src/material/tabs/tab-header.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,34 @@ describe('MatTabHeader', () => {
expect(tabHeaderElement.classList).toContain(enabledClass);
});

it('should scroll to last tab', async(() => {
const tabs = [
{label: 'tab one'},
{label: 'tab one'},
{label: 'tab one'},
{label: 'tab one'},
{label: 'tab one'},
{label: 'tab one'},
{label: 'tab one'},
{label: 'tab one'},
];

fixture = TestBed.createComponent(SimpleTabHeaderApp);
fixture.detectChanges();

const component = fixture.componentInstance;
component.tabs = tabs;
component.selectedIndex = tabs.length - 1;
fixture.detectChanges();

fixture.whenRenderingDone()
.then(() => {
expect(component.tabHeader._disableScrollAfter).toBeTruthy();
expect(component.tabHeader.scrollDistance)
.toEqual(component.tabHeader._getMaxScrollDistance());
});
}));

});
});

Expand Down
1 change: 1 addition & 0 deletions src/material/tabs/tab-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ export class MatTabHeader extends _MatTabHeaderMixinBase
const dirChange = this._dir ? this._dir.change : observableOf(null);
const resize = this._viewportRuler.change(150);
const realign = () => {
this._scrollToLabel(this._selectedIndex);
this.updatePagination();
this._alignInkBarToSelectedTab();
};
Expand Down