@@ -74,6 +74,7 @@ export function NavigationProvider({
7474 setNavigationStack ( [ rootEntry ] ) ;
7575 setCurrentIndex ( 0 ) ;
7676 lastTrackedPath . current = "/" ;
77+ console . warn ( `----- ROOT >>` , rootEntry ) ;
7778
7879 navigate ( "/" , { replace : true } ) ;
7980 } , [ navigate , setNavigationStack , setCurrentIndex ] ) ;
@@ -89,6 +90,7 @@ export function NavigationProvider({
8990 } ;
9091 setNavigationStack ( [ initialEntry ] ) ;
9192 setCurrentIndex ( 0 ) ;
93+ console . warn ( `----- INITIAL_ENTRY >>` , initialEntry ) ;
9294 lastTrackedPath . current = currentPath ;
9395 isInitialized . current = true ;
9496 }
@@ -108,6 +110,8 @@ export function NavigationProvider({
108110 lastTrackedPath . current = currentPath ;
109111 return ;
110112 }
113+ console . warn ( `!!! LOCATION >>` , currentPath , currentPathname ) ;
114+ console . log ( `!!! current >>` , isInitialized , lastTrackedPath , currentIndex , navigationStack . map ( ( p ) => p . path ) ) ;
111115
112116 // Skip if the pathname hasn't actually changed (ignore search params for stack entries)
113117 const previousPathname = lastTrackedPath . current . split ( "?" ) [ 0 ] ;
@@ -129,8 +133,10 @@ export function NavigationProvider({
129133 path : currentPath ,
130134 timestamp : Date . now ( ) ,
131135 } ;
136+ console . log ( `!!! setNavigationStack >>` , prev . length , prev . map ( ( p ) => p . path ) , ">>" , newStack . length , newStack . map ( ( p ) => p . path ) ) ;
132137 return newStack ;
133138 }
139+ console . log ( `!!! setNavigationStack prev >>>>>>>>` , prev . length , prev . map ( ( p ) => p . path ) ) ;
134140 return prev ;
135141 } ) ;
136142
@@ -156,10 +162,10 @@ export function NavigationProvider({
156162 }
157163 }
158164
159- // if equals to the last path, keep new one
160- if ( prev [ currentPosition ] ?. path === newEntry . path ) {
161- currentPosition -- ;
162- }
165+ // // if equals to the last path, keep new one
166+ // if (prev[currentPosition]?.path === newEntry.path) {
167+ // currentPosition--;
168+ // }
163169
164170 // Truncate any forward history and add new entry
165171 const newStack = [ ...prev . slice ( 0 , currentPosition + 1 ) , newEntry ] ;
@@ -168,6 +174,7 @@ export function NavigationProvider({
168174 const newIndex = newStack . length - 1 ;
169175 setCurrentIndex ( newIndex ) ;
170176
177+ console . log ( `!!! setNavigationStack +++` , newIndex , prev . length , prev . map ( ( p ) => p . path ) , ">>" , newStack . length , newStack . map ( ( p ) => p . path ) ) ;
171178 return newStack ;
172179 } ) ;
173180
@@ -232,6 +239,8 @@ export function NavigationProvider({
232239 showClose ?: boolean ;
233240 } ,
234241 ) => {
242+ console . warn ( `::: navigateWithTracking >>` , to , options ) ;
243+ console . log ( `::: current >>` , isInitialized , lastTrackedPath , currentIndex , navigationStack . length , navigationStack . map ( ( p ) => p . path ) ) ;
235244 if ( typeof to === "number" ) {
236245 // Handle relative navigation
237246 const newIndex = currentIndex + to ;
@@ -286,11 +295,14 @@ export function NavigationProvider({
286295 options . showClose ?? newStack [ currentIndex ] . showClose ,
287296 } ;
288297 }
298+ console . log ( `::: setNavigationStack >>` , prev . length , prev . map ( ( p ) => p . path ) , ">>" , newStack . length , newStack . map ( ( p ) => p . path ) ) ;
289299 return newStack ;
290300 } ) ;
301+ console . log ( `::: lastTrackedPath >>` , lastTrackedPath . current ) ;
291302 lastTrackedPath . current = finalPath ;
292303 }
293304
305+ console . log ( `::: navigate >>` , finalPath , options ) ;
294306 navigate ( finalPath , options ) ;
295307 }
296308 } ,
0 commit comments