refactor(tabs): don't deselect previous tab if it's the same as current tab

This commit is contained in:
Dan Bucholtz
2018-01-10 12:08:08 -06:00
parent 81b5cf1fdd
commit 159cc3332a
2 changed files with 5 additions and 21 deletions

View File

@ -98,18 +98,11 @@ export class Tabs {
} }
selectedTab.selected = true; selectedTab.selected = true;
// The same selected was selected
// we need to set root in the nested ion-nav if it exist
/*if (this.selectedTab === selectedTab) {
return selectedTab.goToRoot();
}
*/
const leavingTab = this.selectedTab; const leavingTab = this.selectedTab;
this.selectedTab = selectedTab; this.selectedTab = selectedTab;
let promise = selectedTab.setActive(true); let promise = selectedTab.setActive(true);
if (leavingTab) { if (leavingTab && leavingTab !== selectedTab) {
promise = promise.then(() => leavingTab.setActive(false)); promise = promise.then(() => leavingTab.setActive(false));
} }

View File

@ -11,16 +11,13 @@
</head> </head>
<body> <body>
<ion-tabs> <ion-tabs>
<ion-tab title="Plain List" icon="star" path=""> <ion-tab title="Tab One" icon="star" path="">
<div class="div-one">Div One</div> <div class="div-one" slot="not-initialized">Div One</div>
</ion-tab> </ion-tab>
<ion-tab title="Schedule" icon="globe" path="tab2"> <ion-tab title="Tab Two" icon="globe" path="tab2">
<div class="div-two">Div Two</div> <div class="div-two" slot="not-initialized">Div Two</div>
</ion-tab> </ion-tab>
<ion-tab title="Schedule" icon="save" path="tab2">
<div class="div-three">Div Three</div>
</ion-tabs> </ion-tabs>
<style> <style>
@ -35,12 +32,6 @@
height: 100%; height: 100%;
color: #FFF; color: #FFF;
} }
.div-three {
background-color: green;
height: 100%;
color: #FFF;
}
</style> </style>
</body> </body>
</html> </html>