Skip to content

Commit 4d8afcf

Browse files
author
Douglas Machado
committed
fix(android): added comment to clarify why it's necessary to use the setTimeout
1 parent c93f5bb commit 4d8afcf

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/tabs/index.android.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ export class Tabs extends TabNavigation<TabsBar> {
8686

8787
protected override setTabBarItems(tabItems: com.nativescript.material.core.TabItemSpec[]) {
8888
this.mTabsBar.setItems(tabItems);
89+
// The setTimeout below is necessary to ensure the scrollToTab is executed only after
90+
// all tabs are recreated. The tabs' recreation is triggered by the setItems call above.
91+
//
92+
// The setTimeout is necessary to fix an Android issue:
93+
// Android Issue: Active Tab item not displaying after nav back
94+
// Reproduce steps:
95+
// 1. On app with multiple (overflown) tab items, Switch to the last tab item
96+
// 2. Navigate to a new page
97+
// 3. Nav back to the page with Tabs
98+
// 4. Notice the active last tab item is not showing. The tab strip is showing the most left / initial tab items instead.
8999
setTimeout(() => {
90100
this.mTabsBar.scrollToTab(this.selectedIndex);
91101
}, 0);

0 commit comments

Comments
 (0)