Skip to content

fix(tabs): hidden tabs don't render expansion panels correctly #8825

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
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/demo-app/tabs/tabs-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,41 @@ <h1>Tabs with autosize textarea</h1>
</div>
</mat-tab>
</mat-tab-group>

<h1>Tabs with expansion panel</h1>
<mat-tab-group>
<mat-tab isActive="true" label="">
<ng-template mat-tab-label>
Tab 1
</ng-template>
<mat-accordion multi="true">

<mat-expansion-panel [expanded]="true">
<mat-expansion-panel-header [expandedHeight]="'48px'" [collapsedHeight]="'48px'">
Expanded
</mat-expansion-panel-header>

This content is expanded.

</mat-expansion-panel>

</mat-accordion>

</mat-tab>
<mat-tab label="">
<ng-template mat-tab-label>
Tab 2
</ng-template>
<mat-accordion multi="true">

<mat-expansion-panel>
<mat-expansion-panel-header [expandedHeight]="'48px'" [collapsedHeight]="'48px'">
Collapsed
</mat-expansion-panel-header>

This content is collapsed.

</mat-expansion-panel>
</mat-accordion>
</mat-tab>
</mat-tab-group>
2 changes: 1 addition & 1 deletion src/lib/tabs/tab-body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class MatTabBodyPortal extends CdkPortalOutlet implements OnInit, OnDestr

/** Set initial visibility or set up subscription for changing visibility. */
ngOnInit(): void {
if (this._host._isCenterPosition(this._host._position)) {
if (!this.hasAttached()) {
this.attach(this._host._content);
}
this._centeringSub = this._host._beforeCentering.subscribe((isCentering: boolean) => {
Expand Down