mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-17 18:54:11 +08:00
refactor(tabs): don't deselect previous tab if it's the same as current tab
This commit is contained in:
@ -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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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>
|
||||||
|
Reference in New Issue
Block a user