Skip to content

Commit e0d4597

Browse files
committed
fix(bottom-navigation): fix first fragment not being visible
1 parent 186d57a commit e0d4597

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/bottom-navigation/index.android.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ export class BottomNavigation extends TabNavigationBase {
370370

371371
toLoad.forEach((index) => {
372372
const item = items[index];
373-
if (this.isLoaded && items[index]) {
373+
if (this.isLoaded && item) {
374374
item.loadView(item.content);
375375
}
376376
});
@@ -392,7 +392,9 @@ export class BottomNavigation extends TabNavigationBase {
392392
this._bottomNavigationBar.setVisibility(android.view.View.GONE);
393393
}
394394

395-
this.changeTab(this.selectedIndex);
395+
if (this._attachedToWindow) {
396+
this.changeTab(this.selectedIndex);
397+
}
396398
}
397399

398400
_onAttachedToWindow(): void {
@@ -406,7 +408,12 @@ export class BottomNavigation extends TabNavigationBase {
406408
}
407409

408410
this._attachedToWindow = true;
409-
this.changeTab(this.selectedIndex);
411+
// add a small delay or the getRootFragmentManager wont be the right one
412+
// when "opening" the bottomnavigation page.
413+
// this should be removed once we dont need to use the root fragmentmanager
414+
setTimeout(() => {
415+
this.changeTab(this.selectedIndex);
416+
}, 0);
410417
}
411418

412419
_onDetachedFromWindow(): void {

0 commit comments

Comments
 (0)