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
Expansion panels in factoried content are open initially #16503
Factoried components containing expansion panels will show the expansion panels as open when the component is inside another (like sidenav) that enters the DOM. Non-factoried expansion panels do not have the same issue. Likely related to #11765
While it's still an issue I think needs to be fixed, I ran into this myself and have a workaround that may help other people out for now. If your situation allows, lazy loading (seen at bottom of docs page: https://material.angular.io/components/expansion/overview) and explicitly directing the panels to be closed with <mat-expansion-panel [expanded]="false">, they'll render closed, initially. At least they did for me. I still think it's a bug, but given how long it takes to fix things sometimes, it's probably better than waiting around if you need it.
If your situation allows, lazy loading (seen at bottom of docs page: https://material.angular.io/components/expansion/overview) and explicitly directing the panels to be closed with <mat-expansion-panel [expanded]="false">, they'll render closed, initially.
So the workaround worked for me when I surrounded the content of the expansion panel with:
<ng-templatematExpansionPanelContent>
Your content
</ng-template>
You should end up with your panel looking something like this:
<mat-expansion-panel>
<mat-expansion-panel-header>
This is the expansion title
</mat-expansion-panel-header>
<ng-templatematExpansionPanelContent>
Some deferred content
</ng-template>
</mat-expansion-panel>
A big improvement for me but it's not perfect because the padding-top or margin-top is changing now when it would show the content of the expansion panel before.
Activity
benjaminkimble commentedon Jul 18, 2019
While it's still an issue I think needs to be fixed, I ran into this myself and have a workaround that may help other people out for now. If your situation allows, lazy loading (seen at bottom of docs page: https://material.angular.io/components/expansion/overview) and explicitly directing the panels to be closed with
<mat-expansion-panel [expanded]="false">, they'll render closed, initially. At least they did for me. I still think it's a bug, but given how long it takes to fix things sometimes, it's probably better than waiting around if you need it.lukasbuehler commentedon Sep 7, 2019
So the workaround worked for me when I surrounded the content of the expansion panel with:
You should end up with your panel looking something like this:
As suggested by @benjaminkimble and seen in the docs under as seen in https://material.angular.io/components/expansion/overview#lazy-rendering.
A big improvement for me but it's not perfect because the padding-top or margin-top is changing now when it would show the content of the expansion panel before.
fix(material/expansion): switch away from animations module
fix(material/expansion): switch away from animations module
fix(material/expansion): switch away from animations module (#30119)
fix(material/expansion): switch away from animations module (angular#…
angular-automatic-lock-bot commentedon Jan 5, 2025
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.