You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug(Tabs): Paginator items are not shown if layout of view changes #23206
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/tabsfeatureLabel used to distinguish feature request from other issues
Add or delete tabs so that you have the maximum of tabs shown without having a paginator
Click on "expand" button so that the layout of the view changes
Expected Behavior
I would expect that if the layout of the view changes and the tabs do not have enough space anymore the paginator elements are shown automatically. If the tabs have enough space the paginator elements should disappear.
Actual Behavior
Paginator elements are only added when I resize the window. Not when the layout changes.
Environment
Angular: 12.1.2
CDK/Material: 12.1.2
Browser(s): Chrome
Operating System (e.g. Windows, macOS, Ubuntu): Windows
The reason this happens is that the calculations to check if the paginator should be shown can be expensive, because they can trigger a page layout. In order to limit their impact, we only recalculate the pagination when a tab is added/removed, when the content of the tab header itself changes (based on MutationObserver) or when the page is resized. In order to handle your case, we'd have to either use a ResizeObserver which isn't supported in all browsers, or we'd have to poll the DOM for size changes which will destroy the app's performance.
We may be able to do this automatically once support for IE11 is dropped, but until then we also expose an API that you can use to tell the tabs to recalculate their pagination.
@crisbeto thanks for your response. So are you already providing a API to recalculate? That would be perfectly fine as I have the information when to update anyway. Or are you planning to implement such?
Hmm, I was under the impression that we did, but it seems like we only have one for re-aligning the ink bar. I'll reopen this issue as a feature request. Technically you can access it already if you're comfortable with accessing private APIs. It's at MatTabGroup._tabHeader.updatePagination.
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/tabsfeatureLabel used to distinguish feature request from other issues
Activity
crisbeto commentedon Jul 21, 2021
The reason this happens is that the calculations to check if the paginator should be shown can be expensive, because they can trigger a page layout. In order to limit their impact, we only recalculate the pagination when a tab is added/removed, when the content of the tab header itself changes (based on
MutationObserver) or when the page is resized. In order to handle your case, we'd have to either use aResizeObserverwhich isn't supported in all browsers, or we'd have to poll the DOM for size changes which will destroy the app's performance.We may be able to do this automatically once support for IE11 is dropped, but until then we also expose an API that you can use to tell the tabs to recalculate their pagination.
MeMeMax commentedon Jul 21, 2021
@crisbeto thanks for your response. So are you already providing a API to recalculate? That would be perfectly fine as I have the information when to update anyway. Or are you planning to implement such?
crisbeto commentedon Jul 21, 2021
Hmm, I was under the impression that we did, but it seems like we only have one for re-aligning the ink bar. I'll reopen this issue as a feature request. Technically you can access it already if you're comfortable with accessing private APIs. It's at
MatTabGroup._tabHeader.updatePagination.feat(material/tabs): add API to update the pagination
feat(material/tabs): add API to update the pagination (#23288)
angular-automatic-lock-bot commentedon Feb 15, 2022
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
feat(material/tabs): add API to update the pagination (angular#23288)