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

Problems using accordion inside accordion with Angular 4 #1433

Closed
JoseDRojasA opened this issue Apr 4, 2017 · 15 comments
Closed

Problems using accordion inside accordion with Angular 4 #1433

JoseDRojasA opened this issue Apr 4, 2017 · 15 comments

Comments

@JoseDRojasA
Copy link

JoseDRojasA commented Apr 4, 2017

I need to use an accordion with other accordions inside. When i was using Angular 2, i worked perfect but when i update to angular 4 using angular-cli 1.0, It stops working.

Here is the code:


<ngb-accordion>
    <ngb-panel title="First panel">
        <template ngbPanelContent>
            <ngb-accordion>
                <ngb-panel id="1" title="First panel">
                    <template ngbPanelContent>
                        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird
                        on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table,
                        raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
                    </template>
                </ngb-panel>
            </ngb-accordion>
        </template>
    </ngb-panel>
</ngb-accordion>

@mohammedzamakhan
Copy link

Try to use ng-template instead of template.

@pkozlowski-opensource
Copy link
Member

Please provide a minimal reproduce scenario using plunker as requested in the issue template, otherwise this one is not actionable and will be closed: https://github.com/ng-bootstrap/ng-bootstrap#you-think-youve-found-a-bug

@readme42
Copy link

readme42 commented Apr 4, 2017

@mohammedzamakhan sadly it does not fix it - it breaks everything. It seems that ngbPanelTitle / ngbPanelContent is not working with "ng-template".

This Plunkr shows an accordion not working with ng-template. http://plnkr.co/edit/EBUBLPGNxXAlw9KWrXQD?p=preview

In this plunkr are two accordion panels, one with template, another with ng-template. Only the "template"-one is working.

Notice the config:

var ver = {
    ng: '4.0.1',
    ngRouter: '4.0.1'
  };

@readme42
Copy link

readme42 commented Apr 4, 2017

I've "purged" ;) my comments a little. At the first moment i thougt i ran into the same issue, but now it seems different.
I will investigate more time tomorrow and will open another issue. In short: when placing a custom component into an accordion and the custom component is doing something like "throw new Error(...)", angular crashes without any console output.

@JoseDRojasA i created a plunkr for you which shows nested accordions in angular2.4.1. I cant get them to work, the nested panel title disappears after clicking:
http://plnkr.co/edit/1cZzIEulupwmXBtshP5u?p=preview

@pkozlowski-opensource
Copy link
Member

I guess we should update selectors to allow <ng-template> as well. But I wonder if this makes sense at this point as we are planning to move to Angular 4.x soon (in the next-next-alpha) so I'm not sure it is worth to support both forms.

I'm going to tentatively mark it as an approximate duplicate of #1337

@pkozlowski-opensource
Copy link
Member

As a work-around please keep using <template> for now.

@pkozlowski-opensource
Copy link
Member

Plan for the complete switch to Angular 4 here: #1439

@JoseDRojasA
Copy link
Author

JoseDRojasA commented Apr 27, 2017

I updated my project to Angular 4.1.0 and ng-bootstrap 1.0.0-alpha.25. I changed all templates to ng-template but when i tried to use an accordion with another accordion inside again, the issue persisted.

Here is the plunker: https://plnkr.co/edit/JvsDtOIms69iWSHt3l3B?p=preview

@alexandernst
Copy link

alexandernst commented May 1, 2017

Pretty much the same thing happens with nested tabs: http://plnkr.co/edit/Gu36tzIlg35DNikjR8kt?p=preview

@pankajparkar
Copy link

Here is work around for nested tab by using extra template http://stackoverflow.com/a/43720470/2435473

@pkozlowski-opensource
Copy link
Member

OK, so yesterday I've spent some time with Tobias from the Angular team debugging this issue. It turns out that the root cause is a bug in Angular's handling of queries. I've opened an issue to track resolution of Angular's bug here: angular/angular#16568

Ultimately the solution for this problem will come from angular/angular#16568 but till it is fixed on the Angular side you can use a work-around from http://stackoverflow.com/a/43720470/2435473 (thnx @pankajparkar)

@JrPribs
Copy link

JrPribs commented May 31, 2017

Another solution I found is to wrap the inner accordion in another component, which would essentially do behind the scenes what the previous workaround does.

@pkozlowski-opensource
Copy link
Member

This should be fixed on the Angular side via angular/angular#18326

@pkozlowski-opensource
Copy link
Member

This just got fixed in Angular via angular/angular#18326 so closing it here.

@pkozlowski-opensource
Copy link
Member

Angular 4.3.6 contains a fix for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants