Skip to content

bug(Tabs): Paginator items are not shown if layout of view changes #23206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MeMeMax opened this issue Jul 21, 2021 · 4 comments · Fixed by #23288
Closed

bug(Tabs): Paginator items are not shown if layout of view changes #23206

MeMeMax opened this issue Jul 21, 2021 · 4 comments · Fixed by #23288
Assignees
Labels
area: material/tabs feature This issue represents a new feature or feature request rather than a bug or bug fix P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@MeMeMax
Copy link

MeMeMax commented Jul 21, 2021

Reproduction

Steps to reproduce:

  1. Go to this stackblitz https://stackblitz.com/edit/angular-ptyfdp?file=src/app/tab-group-dynamic-example.html
  2. Add or delete tabs so that you have the maximum of tabs shown without having a paginator
  3. 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
@MeMeMax MeMeMax added the needs triage This issue needs to be triaged by the team label Jul 21, 2021
@crisbeto
Copy link
Member

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 crisbeto added area: material/tabs and removed needs triage This issue needs to be triaged by the team labels Jul 21, 2021
@MeMeMax
Copy link
Author

MeMeMax commented 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
Copy link
Member

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.

@crisbeto crisbeto reopened this Jul 21, 2021
@crisbeto crisbeto added feature This issue represents a new feature or feature request rather than a bug or bug fix P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent labels Jul 21, 2021
@crisbeto crisbeto self-assigned this Aug 1, 2021
@crisbeto crisbeto added the has pr label Aug 1, 2021
crisbeto added a commit to crisbeto/material2 that referenced this issue Aug 1, 2021
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 angular#23206.
andrewseguin pushed a commit that referenced this issue Jan 15, 2022
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.
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Feb 15, 2022
forsti0506 pushed a commit to forsti0506/components that referenced this issue Apr 3, 2022
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 angular#23206.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: material/tabs feature This issue represents a new feature or feature request rather than a bug or bug fix P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants