@@ -188,7 +188,6 @@ export class BottomNavigation extends TabNavigationBase {
188188 private _bottomNavigationBar : org . nativescript . widgets . BottomNavigationBar ;
189189 private _currentFragment : androidx . fragment . app . Fragment ;
190190 private _currentTransaction : androidx . fragment . app . FragmentTransaction ;
191- private _timeoutId : number = - 1 ;
192191
193192 constructor ( ) {
194193 super ( ) ;
@@ -374,30 +373,20 @@ export class BottomNavigation extends TabNavigationBase {
374373 // TODO: Should we extract adapter-like class?
375374 // TODO: Rename this?
376375 public changeTab ( index : number ) {
377- if ( this . _timeoutId !== - 1 ) {
378- clearTimeout ( this . _timeoutId ) ;
379- this . _timeoutId = - 1 ;
376+ // this is the case when there are no items
377+ if ( index === - 1 ) {
378+ return ;
380379 }
381380
382- // TODO: find better way to ensure we are not executing this logic multiple times on a single pass
383- this . _timeoutId = setTimeout ( ( ) => {
384- // this is the case when there are no items
385- if ( index === - 1 ) {
386- return ;
387- }
388-
389- const fragmentToDetach = this . _currentFragment ;
390- if ( fragmentToDetach ) {
391- this . destroyItem ( ( < any > fragmentToDetach ) . index , fragmentToDetach ) ;
392- }
393-
394- const fragment = this . instantiateItem ( this . _contentView , index ) ;
395- this . setPrimaryItem ( index , fragment ) ;
381+ const fragmentToDetach = this . _currentFragment ;
382+ if ( fragmentToDetach ) {
383+ this . destroyItem ( ( < any > fragmentToDetach ) . index , fragmentToDetach ) ;
384+ }
396385
397- this . commitCurrentTransaction ( ) ;
386+ const fragment = this . instantiateItem ( this . _contentView , index ) ;
387+ this . setPrimaryItem ( index , fragment ) ;
398388
399- this . _timeoutId = - 1 ;
400- } ) ;
389+ this . commitCurrentTransaction ( ) ;
401390 }
402391
403392 private instantiateItem ( container : android . view . ViewGroup , position : number ) : androidx . fragment . app . Fragment {
0 commit comments