I have a computed property that uses the current route to calculate the tab that the user is current on using this code:
const activeTabIndex = computed(() => {
const route = useRoute();
return navigation.findIndex((e) => {
return route.fullPath.startsWith(e.href);
});
});
However, testing it using this code:
router.afterEach((to, from) => {
console.log(activeTabIndex.value);
});
Yields that the index only updates after the page is visited while already on it (and this is reflected in the actual UI). Basically:
- User click page X
- URL updates to X
- User clicks page X again
- Tab index updates to X