Skip to content
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

Expansion panels in factoried content are open initially #16503

Closed
pburkindine opened this issue Jul 11, 2019 · 3 comments · Fixed by #30119
Closed

Expansion panels in factoried content are open initially #16503

pburkindine opened this issue Jul 11, 2019 · 3 comments · Fixed by #30119
Assignees
Labels
area: material/expansion P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@pburkindine
Copy link

pburkindine commented Jul 11, 2019

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

Reproduction

https://stackblitz.com/edit/sidenav-accordion-expansion

Steps to reproduce:

  1. Open the sidenav
  2. Should see the accordion is open during sidenav enter

Expected Behavior

Sidenav should not be open during sidenav enter

Environment

  • Angular: 8
  • CDK/Material: 8
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): OSX High Sierra
@benjaminkimble
Copy link

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.

@andrewseguin andrewseguin added the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label Jul 19, 2019
@lukasbuehler
Copy link

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-template matExpansionPanelContent>
    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-template matExpansionPanelContent>
        Some deferred content
    </ng-template>
</mat-expansion-panel>

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.

@crisbeto crisbeto self-assigned this Dec 5, 2024
crisbeto added a commit to crisbeto/material2 that referenced this issue Dec 5, 2024
Reworks the expansion panel to animate purely with CSS, rather than going through the `@angular/animations` module. This simplifies the setup and allows us to resolve several long-standing bug reports.

Fixes angular#27946.
Fixes angular#22715.
Fixes angular#21434.
Fixes angular#20610.
Fixes angular#20517.
Fixes angular#17177.
Fixes angular#16534.
Fixes angular#16503.
Fixes angular#14952.
Fixes angular#14759.
Fixes angular#14075.
Fixes angular#11765.
crisbeto added a commit to crisbeto/material2 that referenced this issue Dec 5, 2024
Reworks the expansion panel to animate purely with CSS, rather than going through the `@angular/animations` module. This simplifies the setup and allows us to resolve several long-standing bug reports.

Fixes angular#27946.
Fixes angular#22715.
Fixes angular#21434.
Fixes angular#20517.
Fixes angular#17177.
Fixes angular#16534.
Fixes angular#16503.
Fixes angular#14952.
Fixes angular#14759.
Fixes angular#14075.
Fixes angular#11765.
crisbeto added a commit that referenced this issue Dec 5, 2024
Reworks the expansion panel to animate purely with CSS, rather than going through the `@angular/animations` module. This simplifies the setup and allows us to resolve several long-standing bug reports.

Fixes #27946.
Fixes #22715.
Fixes #21434.
Fixes #20517.
Fixes #17177.
Fixes #16534.
Fixes #16503.
Fixes #14952.
Fixes #14759.
Fixes #14075.
Fixes #11765.

(cherry picked from commit aafa151)
@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 Jan 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: material/expansion 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.

5 participants