@@ -20,18 +20,29 @@ const routes = useMergedRouteList()
2020
2121const middleware = computed (() => serverApp .value ?.middleware || [])
2222const routeInput = ref (' ' )
23+ const count = ref (0 )
24+
25+ const currentRoute = computed (() => {
26+ // Additionall reactivity tracker
27+ // eslint-disable-next-line no-unused-expressions
28+ (middleware .value , routeInput .value , layouts .value , count .value )
29+ return router .value ?.currentRoute .value .path
30+ })
2331
2432onMounted (() => {
2533 if (route .value )
26- routeInput .value = route .value .path
34+ routeInput .value = router . value ?. currentRoute .value .path
2735
36+ router .value ?.beforeEach ((to ) => {
37+ routeInput .value = to .fullPath
38+ })
2839 router .value ?.afterEach ((to ) => {
2940 routeInput .value = to .fullPath
3041 })
3142})
3243
3344async function navigate() {
34- if (routeInput .value !== route .value .path )
45+ if (routeInput .value !== router . value ?. currentRoute .value .path )
3546 router .value .push (routeInput .value || ' /' )
3647}
3748
@@ -49,9 +60,9 @@ function navigateToRoute(path: string) {
4960 <div v-if =" config?.pages && router" h-full of-auto >
5061 <div border =" b base" flex =" ~ col gap1" px4 py3 n-navbar-glass >
5162 <div >
52- <template v-if =" route . path !== routeInput " >
63+ <template v-if =" currentRoute !== routeInput " >
5364 <span op50 >Navigate from </span >
54- <span font-mono >{{ route.path }}</span >
65+ <span font-mono >{{ currentRoute }}</span >
5566 <span op50 > to </span >
5667 </template >
5768 <template v-else >
@@ -62,11 +73,11 @@ function navigateToRoute(path: string) {
6273 v-model =" routeInput"
6374 font-mono
6475 icon =" carbon-direction-right-01 scale-y--100"
65- :class =" route.path === routeInput ? '' : routeInputMatched.length ? 'text-green' : 'text-orange'"
76+ :class =" currentRoute === routeInput ? '' : routeInputMatched.length ? 'text-green' : 'text-orange'"
6677 @keydown.enter =" navigate"
6778 />
6879 <div >
69- <template v-if =" route . path !== routeInput " >
80+ <template v-if =" currentRoute !== routeInput " >
7081 <span >Press <b font-bold >Enter</b > to navigate</span >
7182 <span v-if =" !routeInputMatched.length" text-orange op75 > (no match)</span >
7283 </template >
0 commit comments