@@ -65,30 +65,18 @@ export class Tabs implements NavOutlet {
6565    this . ionNavWillLoad . emit ( ) ; 
6666  } 
6767
68-   componentWillRender ( )  { 
68+   componentDidLoad ( )  { 
69+     this . updateTabBar ( ) ; 
70+   } 
71+ 
72+   componentDidUpdate ( )  { 
73+     this . updateTabBar ( ) ; 
74+   } 
75+ 
76+   private  updateTabBar ( )  { 
6977    const  tabBar  =  this . el . querySelector ( 'ion-tab-bar' ) ; 
7078    if  ( tabBar )  { 
71-       let  tab  =  this . selectedTab  ? this . selectedTab . tab  : undefined ; 
72- 
73-       // Fallback: if no selectedTab is set but we're using router mode, 
74-       // determine the active tab from the current URL. This works around 
75-       // timing issues in React Router integration where setRouteId may not 
76-       // be called in time for the initial render. 
77-       // TODO(FW-6724): Remove this with React Router upgrade 
78-       if  ( ! tab  &&  this . useRouter  &&  typeof  window  !==  'undefined' )  { 
79-         const  currentPath  =  window . location . pathname ; 
80-         const  tabButtons  =  this . el . querySelectorAll ( 'ion-tab-button' ) ; 
81- 
82-         // Look for a tab button that matches the current path pattern 
83-         for  ( const  tabButton  of  tabButtons )  { 
84-           const  tabId  =  tabButton . getAttribute ( 'tab' ) ; 
85-           if  ( tabId  &&  currentPath . includes ( tabId ) )  { 
86-             tab  =  tabId ; 
87-             break ; 
88-           } 
89-         } 
90-       } 
91- 
79+       const  tab  =  this . selectedTab  ? this . selectedTab . tab  : undefined ; 
9280      tabBar . selectedTab  =  tab ; 
9381    } 
9482  } 
@@ -162,6 +150,7 @@ export class Tabs implements NavOutlet {
162150    this . selectedTab  =  selectedTab ; 
163151    this . ionTabsWillChange . emit ( {  tab : selectedTab . tab  } ) ; 
164152    selectedTab . active  =  true ; 
153+     this . updateTabBar ( ) ; 
165154    return  Promise . resolve ( ) ; 
166155  } 
167156
0 commit comments