Skip to content

[Tabs] Hidden tabs don't render expansion panels correctly #5269

Closed

Description

@AlanCrevon

Bug, feature request, or proposal:

Bug.

What is the expected behavior?

A <md-expansion-panel [expanded]="false"> should not be expanded until explicitally opened.
When inside a hidden tab, .mat-expansion-panel-content should have height : 0px

What is the current behavior?

Panel is collapsed but panetl's content is visible. Problem occurs only if the accordion is in a hidden tab of a tab-group.

What are the steps to reproduce?

http://plnkr.co/edit/q6kXPH?p=preview

  <md-tab label="Working">
    <md-accordion>
        <md-expansion-panel [expanded]="false">
        <md-expansion-panel-header>
          You should see me
        </md-expansion-panel-header>
        <p>Yous should not see me</p>
      </md-expansion-panel>
    </md-accordion>
  </md-tab>
  <md-tab label="Not working">
    <md-accordion>
        <md-expansion-panel [expanded]="false">
        <md-expansion-panel-header>
          You should see me
        </md-expansion-panel-header>
        <p>Yous should not see me</p>
      </md-expansion-panel>
    </md-accordion>
  </md-tab>
</md-tab-group>

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Material2 master
Angular 4.2.3

Activity

  1. changed the title [-]md-expansion-panel : started collapsed[/-] [+]md-expansion-panel : start collapsed[/+] on Jun 21, 2017
  2. julianobrasil commented on Jun 21, 2017

    @julianobrasil
    Contributor

    It seems to be working correctly here: http://plnkr.co/edit/q6kXPH?p=preview

  3. AlanCrevon commented on Jun 21, 2017

    @AlanCrevon
    Author

    correct. It's also working in another page of mine. Currently trying to isolate the pb.

  4. AlanCrevon commented on Jun 21, 2017

    @AlanCrevon
    Author

    Ok, i edit the issue : the problem occurs only if the element is in a hidden tab. Thanks @julianobrasil

  5. changed the title [-]md-expansion-panel : start collapsed[/-] [+]md-expansion-panel : collapsed in tabs[/+] on Jun 21, 2017
  6. julianobrasil commented on Jun 21, 2017

    @julianobrasil
    Contributor

    OK. Updated the plunker to reproduce it: http://plnkr.co/edit/q6kXPH?p=preview

    Put it in the issue.

  7. emoralesb05 commented on Jun 21, 2017

    @emoralesb05
    Contributor

    This actually happens to anything that contains an animation when set inside a hidden md-tab.

  8. mzernetsch commented on Jun 21, 2017

    @mzernetsch

    This seems to be caused by angular 4.2 changes.
    I use Teradata Covalent expansion panels in my app which have the same problem since the new angular version: https://gitter.im/Teradata/covalent?at=593e58f06549436c7d3c8360

  9. julianobrasil commented on Jun 28, 2017

    @julianobrasil
    Contributor

    😉 A very unacceptable workaround (but useful if you can't wait for the next release, possibly without this bug) is using a *ngIf and just show the accordion/expansion panel when it's needed (if it's needed when the page is loaded, put a variable in a setTimeout to trigger *ngIf in about 4 to 5 seconds after the tab-group has been rendered, or use the tab change event). In this case the expansion is shown in its expected state (collapsed or expanded).

  10. lebeker commented on Aug 31, 2017

    @lebeker

    Hey! that bug is really annoying, is there any hope to see it's fix?) Maybe applying @julianobrasil solution with *ngIf=isActive on tabs content?

  11. julianobrasil commented on Aug 31, 2017

    @julianobrasil
    Contributor

    @lebeker, I've been using something like that in a project: http://plnkr.co/edit/YAi6Xb?p=preview

    I tried isActive (*ngIf="mdTab.isActive" where mdTab is a reference template variable), but it causes a "changed after checked" error.

  12. lula commented on Sep 1, 2017

    @lula

    Hello! @julianobrasil, following @lebeker advice that's working for me as a workaround:

    <md-tab-group [(selectedIndex)]="selectedTabIndex">
      <md-tab label="First">
        <div>...</div>
      </md-tab>
      <md-tab label="Second">
        <div *ngIf="selectedTabIndex == 1">...</div>
      <md-tab>
      <md-tab label="Third">
        <div *ngIf="selectedTabIndex == 2">...</div>
      <md-tab>
    </md-tab-group>
    
  13. Puresoft commented on Sep 5, 2017

    @Puresoft

    @lula worked for me, thanks!

  14. michalmw commented on Sep 11, 2017

    @michalmw

    @lula Can you show your component.ts file?

  15. 91 remaining items

  16. jonyadamit commented on Dec 23, 2018

    @jonyadamit

    by the way.. you can easily confirm issue resolved by going to my demo for this issue, see it as it is, update dependencies, reload - and see everything works fine!

  17. hijazikaram commented on Jan 23, 2019

    @hijazikaram

    im still having the issue

  18. ignacionoguerol commented on Jan 29, 2019

    @ignacionoguerol

    I just fixed it by lazy loading the non-default tab.

    https://material.angular.io/components/tabs/overview#lazy-loading

  19. zahasoftware commented on Feb 20, 2019

    @zahasoftware

    6/7
    Applying your own animations does not work, where you put the animation the control disappears

  20. ThomasAdr commented on Jul 31, 2019

    @ThomasAdr

    Issue still exists in version 8.

  21. Sieabah commented on Aug 3, 2019

    @Sieabah

    When will this library be comparable to the material-ui that react has?

    React currently has a better material component library than Google's own material library

  22. shlomoa commented on Oct 7, 2019

    @shlomoa

    This is not specific to MatTab, it is happening when accordion is embedded
    Also in MatTree MatTable etc.

  23. philipschikora commented on Nov 13, 2019

    @philipschikora

    +1

  24. chaitraRastogi commented on Apr 21, 2020

    @chaitraRastogi

    This worked for me

    :host /deep/ .mat-expansion-panel-content:not(.mat-expanded) {
    height: 0;
    visibility: hidden;
    }

    :host
    /deep/
    .mat-expansion-panel-header:active

    :host
    /deep/
    .mat-expansion-panel-content.mat-expanded {
    visibility: visible;
    }

    If we don't want to upgrade the angular version

  25. self-assigned this
    on Dec 2, 2022
  26. mmalerba commented on Dec 2, 2022

    @mmalerba
    Contributor

    Confirmed that this work in v15 https://stackblitz.com/edit/angular-pmsgwg

  27. angular-automatic-lock-bot commented on Jan 2, 2023

    @angular-automatic-lock-bot

    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.

  28. locked and limited conversation to collaborators on Jan 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

GP3area: material/tabs

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions