Good day.
I trying set active tab inactive after second click, but ionSelect not firing for current tab item.
Is there any way to do it?
This sounds like a bad UI to me. How can you have a tab that is simultaneously active and inactive?
See if one of the many things in here would solve your problem: Click event for ion-tab?
Yes, its bad UI, but it in need by design
Same problem for me : root = null; doesn’t work
I wrote the following on StencilJS but I must admit I don’t like it very much since it was necessary to declare data-tab
as a custom attribute on <ion-tab />
and on its corresponding <ion-tab-button />
.
<ion-tabs>
<ion-tab data-tab="tab-something" tab="tab-something" >
<ion-nav><p>something</p></ion-nav>
</ion-tab>
<ion-tab-bar>
<ion-tab-button data-tab="tab-something" tab="tab-something" onClick={() => this.toggleTab('tab-something')}>
<ion-icon name="list-outline"></ion-icon>
<ion-label>something</ion-label>
</ion-tab-button>
</ion-tab-bar>
</ion-tabs>
toggleTab(datatab: string): void {
const ionTabButton = this.el.querySelector(`ion-tab-button[data-tab="${datatab}"]`) as HTMLIonTabButtonElement;
ionTabButton.selected = !ionTabButton.selected;
const ionTab = this.el.querySelector(`ion-tab[data-tab="${datatab}"]`) as HTMLIonTabElement;
ionTab.active = !ionTab.active;
};