Skip to content

Commit b363af2

Browse files
committed
fix(tabs): Android, restore state issue
Do not try and remove the tabs bar if the native view is newly created.
1 parent d04c43d commit b363af2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/core-tabs/tab-navigation/index.android.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ export abstract class TabNavigation<T extends android.view.ViewGroup = any> exte
238238
this.mViewPager = viewPager;
239239
setElevation(nativeView, null, this.tabsPosition);
240240
if (this.tabStrip) {
241-
this.handleTabStripChanged(nativeView, null, this.tabStrip);
241+
this.handleTabStripChanged(nativeView, true, this.tabStrip);
242242
}
243243

244244
return nativeView;
@@ -250,9 +250,9 @@ export abstract class TabNavigation<T extends android.view.ViewGroup = any> exte
250250
protected abstract getTabBarItemTextView(index: number);
251251
protected abstract selectTabBar(oldIndex: number, newIndex: number);
252252

253-
private handleTabStripChanged(nativeView: org.nativescript.widgets.GridLayout, oldTabStrip: TabStrip, newTabStrip: TabStrip) {
253+
private handleTabStripChanged(nativeView: org.nativescript.widgets.GridLayout, isNewView: boolean, newTabStrip: TabStrip) {
254254
if (this.mTabsBar) {
255-
nativeView.removeView(this.mTabsBar);
255+
if (!isNewView) nativeView.removeView(this.mTabsBar);
256256
nativeView['tabsBar'] = null;
257257
this.mTabsBar = null;
258258
}
@@ -276,7 +276,7 @@ export abstract class TabNavigation<T extends android.view.ViewGroup = any> exte
276276
if (!nativeView) {
277277
return;
278278
}
279-
this.handleTabStripChanged(nativeView, oldTabStrip, newTabStrip);
279+
this.handleTabStripChanged(nativeView, false, newTabStrip);
280280
}
281281

282282
onSelectedIndexChanged(oldIndex: number, newIndex: number) {

0 commit comments

Comments
 (0)