Skip to content

Commit 445eb04

Browse files
crisbetommalerba
authored andcommitted
fix(material/tabs): pagination not updating on resize (#22442)
The tab header pagination wasn't updating when the page is resized, because the resize listener runs outside of Angular. Fixes #22399. (cherry picked from commit 30ea79a)
1 parent 1ed3e5f commit 445eb04

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/material/tabs/paginated-tab-header.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,10 @@ export abstract class MatPaginatedTabHeader implements AfterContentChecked, Afte
201201
// On dir change or window resize, realign the ink bar and update the orientation of
202202
// the key manager if the direction has changed.
203203
merge(dirChange, resize, this._items.changes).pipe(takeUntil(this._destroyed)).subscribe(() => {
204-
// We need to defer this to give the browser some time to recalculate the element dimensions.
205-
Promise.resolve().then(realign);
204+
// We need to defer this to give the browser some time to recalculate
205+
// the element dimensions. The call has to be wrapped in `NgZone.run`,
206+
// because the viewport change handler runs outside of Angular.
207+
this._ngZone.run(() => Promise.resolve().then(realign));
206208
this._keyManager.withHorizontalOrientation(this._getLayoutDirection());
207209
});
208210

0 commit comments

Comments
 (0)