mat-tab-group that starts in hidden container does not show selection in header
See original GitHub issueWhat is the expected behavior?
When a tab group starts inside a container element that is hidden using [hidden]
. Once the container element becomes visible the tab should render correctly and show the default selection in the header.
What is the current behavior?
If the mat-tab-group is inside a container ( for example <div>
) that is hidden using [hidden]
when a component renders the first time. When you set hidden to false afterwards to show the tab group the selection is not visible in the tab header. After you click to a different tab the header refreshes and then the selection is shown as expected.
What are the steps to reproduce?
Here is a StackBlitz sample that reproduces the issue. Once you click the button to make the tab group visible you can see that the header has no selection.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
- Angular: 7.0.0 and 7.1.2
- Angular Material: 7.0.1 and 7.1.1
- OS: Windows: 10
- TypeScript: 3.1.3
- Browser: Version 70.0.3538.110 (Official Build) (64-bit)
Is there anything else we should know?
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (1 by maintainers)
Top Results From Across the Web
Angular material mat tab group in hidden container does not ...
A workaround I found to make my ink bar update and pagination occur correctly was to add a method to manually update header...
Read more >Tabs - Angular Material
Supports string and string array values, same as ngClass . Plain text label for the tab, used when there is no template label....
Read more >Control tab group appearance and behavior - MATLAB
Tab groups are containers for grouping and managing tabs. Use the uitabgroup function to create a tab group. By changing property values of...
Read more >Tab group with dynamically changing tabs - StackBlitz
<span class="example-input-label"> Selected. tab index: </span> ... <mat-checkbox #selectAfterAdding> Select ... <mat-tab-group [selectedIndex]="selected.
Read more >Angular Material mat-tab-group - GeeksforGeeks
mat-tab-group is used mainly for navbar requirements when we have multiple tabs to display. Installation: ng add @angular/material. Approach:.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You can force the ink bar to re-align by calling
realignInkBar()
.https://stackblitz.com/edit/angular-3srg4v-gylvb5?file=app%2Ftab-group-basic-example.ts
The downside to this is that the ink bar will transition in, which may not be your intended effect.
We can explore the possibility of calling the function with a param that removes the animation. If you’d like this, feel free to open a new issue with the feature request.
You can use selectedIndex on the <mat-tabs-group> element to store the current tab index.
See updated Stackblitz: https://stackblitz.com/edit/realighinkbar-example