@@ -17,6 +17,7 @@ import { getLocalStorageItem, setLocalStorageItem } from '@/lib/browser';
1717import  {  tcls  }  from  '@/lib/tailwind' ; 
1818import  {  Icon  }  from  '@gitbook/icons' ; 
1919import  {  useRouter  }  from  'next/navigation' ; 
20+ import  {  assert  }  from  'ts-essentials' ; 
2021
2122interface  TabsState  { 
2223 activeIds : { 
@@ -87,7 +88,7 @@ export function DynamicTabs(props: {
8788 ) ; 
8889 } ,  [ id ,  tabs ,  tabsState ] ) ; 
8990
90-  // Track is  the tab has been touched by the user. 
91+  // Track if  the tab has been touched by the user. 
9192 const  touchedRef  =  useRef ( false ) ; 
9293
9394 // To avoid issue with hydration, we only use the state from localStorage 
@@ -133,13 +134,14 @@ export function DynamicTabs(props: {
133134 : prev . activeTitles , 
134135 } ; 
135136 } ) ; 
136-  setInitialized ( true ) ; 
137137 } , 
138138 [ router ,  setTabsState ,  tabs ,  id ] 
139139 ) ; 
140140
141141 // When the hash changes, we try to select the tab containing the targetted element. 
142142 React . useLayoutEffect ( ( )  =>  { 
143+  setInitialized ( true ) ; 
144+ 143145 if  ( hash )  { 
144146 // First check if the hash matches a tab ID. 
145147 const  hashIsTab  =  tabs . some ( ( tab )  =>  tab . id  ===  hash ) ; 
@@ -160,11 +162,6 @@ export function DynamicTabs(props: {
160162 } 
161163
162164 selectTab ( tabPanel . id ,  false ) ; 
163-  }  else  { 
164-  const  firstTab  =  tabs [ 0 ] ; 
165-  if  ( firstTab )  { 
166-  selectTab ( firstTab . id ,  false ) ; 
167-  } 
168165 } 
169166 } ,  [ selectTab ,  tabs ,  hash ] ) ; 
170167
0 commit comments