chore(): fix tabs (#19821)

* fix(tabs): do not wait on child tab setActive() lazy loading

* whenDefined example

* chore(): fix lint
This commit is contained in:
Mike Hartington
2019-11-01 09:29:30 -07:00
committed by GitHub
parent 7bd4412889
commit 60aa027903
4 changed files with 22 additions and 9 deletions

View File

@ -46,7 +46,9 @@ export class Tabs implements NavOutlet {
}
if (!this.useRouter) {
const tabs = this.tabs;
await this.select(tabs[0]);
if (tabs.length > 0) {
await this.select(tabs[0]);
}
}
this.ionNavWillLoad.emit();
}
@ -127,7 +129,8 @@ export class Tabs implements NavOutlet {
this.leavingTab = this.selectedTab;
this.selectedTab = selectedTab;
this.ionTabsWillChange.emit({ tab: selectedTab.tab });
return selectedTab.setActive();
selectedTab.active = true;
return Promise.resolve();
}
private tabSwitch() {

View File

@ -12,7 +12,7 @@
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script>
</head>
<body onload="selectTab()">
<body>
<ion-tabs>
<ion-tab tab="tab-one">
<div class="content-div div-one">
@ -71,11 +71,11 @@
</style>
<script>
async function selectTab() {
customElements.whenDefined('ion-tabs').then(async () => {
const tabs = document.querySelector('ion-tabs');
await tabs.componentOnReady();
await tabs.select('tab-three');
}
});
</script>
</body>