Skip to content
Merged
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
3 changes: 2 additions & 1 deletion src/material/tabs/paginated-tab-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ export abstract class MatPaginatedTabHeader implements AfterContentChecked, Afte
// On dir change or window resize, realign the ink bar and update the orientation of
// the key manager if the direction has changed.
merge(dirChange, resize, this._items.changes).pipe(takeUntil(this._destroyed)).subscribe(() => {
realign();
// We need to defer this to give the browser some time to recalculate the element dimensions.
Promise.resolve().then(realign);
this._keyManager.withHorizontalOrientation(this._getLayoutDirection());
});

Expand Down
10 changes: 6 additions & 4 deletions src/material/tabs/tab-nav-bar/tab-nav-bar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,27 +142,29 @@ describe('MatTabNavBar', () => {
expect(tabLinkElement.classList).toContain('mat-tab-disabled');
});

it('should re-align the ink bar when the direction changes', () => {
it('should re-align the ink bar when the direction changes', fakeAsync(() => {
const inkBar = fixture.componentInstance.tabNavBar._inkBar;

spyOn(inkBar, 'alignToElement');

dirChange.next();
tick();
fixture.detectChanges();

expect(inkBar.alignToElement).toHaveBeenCalled();
});
}));

it('should re-align the ink bar when the tabs list change', () => {
it('should re-align the ink bar when the tabs list change', fakeAsync(() => {
const inkBar = fixture.componentInstance.tabNavBar._inkBar;

spyOn(inkBar, 'alignToElement');

fixture.componentInstance.tabs = [1, 2, 3, 4];
fixture.detectChanges();
tick();

expect(inkBar.alignToElement).toHaveBeenCalled();
});
}));

it('should re-align the ink bar when the tab labels change the width', done => {
const inkBar = fixture.componentInstance.tabNavBar._inkBar;
Expand Down