Skip to content

Commit b9a3908

Browse files
authoredJan 15, 2022
feat(material/tabs): add API to update the pagination (#23288)
We try to update the pagination state of the tab group very sparingly, because it has performance implications. This means that we may miss some updates. These changes expose a method so that consumers can trigger a recalculation on their own. Fixes #23206.
1 parent b851456 commit b9a3908

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed
 

‎src/material/tabs/tab-group.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ const _MatTabGroupMixinBase = mixinColor(
7171
);
7272

7373
interface MatTabGroupBaseHeader {
74-
_alignInkBarToSelectedTab: () => void;
74+
_alignInkBarToSelectedTab(): void;
75+
updatePagination(): void;
7576
focusIndex: number;
7677
}
7778

@@ -327,6 +328,19 @@ export abstract class _MatTabGroupBase
327328
}
328329
}
329330

331+
/**
332+
* Recalculates the tab group's pagination dimensions.
333+
*
334+
* WARNING: Calling this method can be very costly in terms of performance. It should be called
335+
* as infrequently as possible from outside of the Tabs component as it causes a reflow of the
336+
* page.
337+
*/
338+
updatePagination() {
339+
if (this._tabHeader) {
340+
this._tabHeader.updatePagination();
341+
}
342+
}
343+
330344
/**
331345
* Sets focus to a particular tab.
332346
* @param index Index of the tab to be focused.

‎tools/public_api_guard/material/tabs.md

+1
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ export abstract class _MatTabGroupBase extends _MatTabGroupMixinBase implements
260260
// (undocumented)
261261
abstract _tabHeader: MatTabGroupBaseHeader;
262262
_tabs: QueryList<MatTab>;
263+
updatePagination(): void;
263264
// (undocumented)
264265
static ɵdir: i0.ɵɵDirectiveDeclaration<_MatTabGroupBase, never, never, { "dynamicHeight": "dynamicHeight"; "selectedIndex": "selectedIndex"; "headerPosition": "headerPosition"; "animationDuration": "animationDuration"; "contentTabIndex": "contentTabIndex"; "disablePagination": "disablePagination"; "backgroundColor": "backgroundColor"; }, { "selectedIndexChange": "selectedIndexChange"; "focusChange": "focusChange"; "animationDone": "animationDone"; "selectedTabChange": "selectedTabChange"; }, never>;
265266
// (undocumented)

0 commit comments

Comments
 (0)