ngx-bootstrap: fix(tabs): order not working with ngIf\dynamic directives
I have been using tab directive.Additionally i used ngIf directive inside tab selector.Everything is right.But tab order not regular.It is not order as I want .Here my code:
<tabset [justified]="true">
<tab (select)="showCustomer()" *ngIf="isRoleCustomer" >
<template tabHeading>Customers</template>
<customers></customers>
</tab>
<tab (select)="showProgram()" *ngIf="isRoleProgram">
<template tabHeading>Programs</template>
<programs [role]="_isRole"></programs>
</tab>
<tab (select)="showMessage()" >
<template tabHeading>Message Templates</template>
<message-templates></message-templates>
</tab>
</tabset>
This is tab order as (message | customers | programs) in this code.But i want to be like (customers| programs| messages) of tab order.So is there any order input property like tabIndex and tabOrder.
About this issue
- Original URL
- State: open
- Created 8 years ago
- Reactions: 13
- Comments: 30
Commits related to this issue
- chore(tabs): new tabs behavior based on @ContentChildren Closes #1719 #823 — committed to buchslava/angular2-bootstrap by buchslava 7 years ago
- chore(tabs): new tabs behavior based on @ContentChildren Closes #1719 #823 — committed to buchslava/angular2-bootstrap by buchslava 7 years ago
- chore(tabs): new tabs behavior based on @ContentChildren Closes #1719 #823 — committed to buchslava/angular2-bootstrap by buchslava 7 years ago
- fix(tab): fix incorrect order of tabs when adding structural directive (#823) — committed to MilaLysenko/ngx-bootstrap by deleted user 6 years ago
- fix(tab): fix incorrect order of tabs when adding structural directive (#823) — committed to MilaLysenko/ngx-bootstrap by deleted user 6 years ago
- fix(tab): fix incorrect order of tabs when adding structural directive (#823) — committed to MilaLysenko/ngx-bootstrap by deleted user 6 years ago
- fix(tab): fix incorrect order of tabs when adding structural directive (#823) — committed to MilaLysenko/ngx-bootstrap by deleted user 6 years ago
- fix(tab): fix incorrect order of tabs when adding structural directive (#823) — committed to MilaLysenko/ngx-bootstrap by deleted user 6 years ago
- fix(tab): fix incorrect order of tabs when adding structural directive (#823) — committed to MilaLysenko/ngx-bootstrap by deleted user 6 years ago
- fix(tab): fix incorrect order of tabs when adding structural directive (#823) — committed to MilaLysenko/ngx-bootstrap by deleted user 6 years ago
Below is a directive which you can use to specify tab order. Instead of relying on
idfield which might be used for something else, it “patches” the object with__tabOrderproperty.usage:
As a workaround, just add *ngIf=“true” to any tab elements that don’t have an *ngIf. Issue seems to be lifecycle related.
+1 same issue, I don’t see any ‘index’ functionality that was previously mentioned either.
+1 I tried the *ngIf=“true” word around but it didn’t work.
I have done working workaround using customClass and adding ‘_HIDDEN’ sufix to my customClass
<tab customClass="MY_CLASS_NAME{{!show ? '_HIDDEN' : ''}}">Class MY_CLASS_NAME_HIDDEN has just:display: none !important;Important: When you need to show/hide 1st tab, you need to control tab [active] property on your tabs, because when you will hide 1st tab that was active, it will look like no tab is active.
has tvoloshyn’s solution been considered for production?
I’ve found one solution for today. It doesn’t look like a good solution but as is.
I have a tab component inspired by this. I ended up sorting the tabs by id upon ceration. Something in the lines of:
Just had to move the addTab invocation from the constructor to ngOnInit to get the id
I wonder if there’s anything less intrusive to know the relative positions of the tabs… ElementRef ?
The solution provided by @romanszedzielorz is the only one working - adding *ngIf to all tabs works only until a change to *ngIf condition is detected in the middle element - if it is the case, if condition is true, tab is moved to the end instead staying in the place as declared. Index does not work. Please consider it a serious problem as any dynamic tabs declared other than items in a list are not handled correctly.