Skip to content

Commit 6f989ed

Browse files
committed
BsListNavItem, BsListTile, BsTab, BsTabItem: update routeMatcher to indicate the element is active or not
1 parent 44685ed commit 6f989ed

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/mixins/CommonApi.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,18 @@ export function useCurrentRoute(): Ref<RouteLocationNormalizedLoaded> | undefine
255255
return vm?.appContext.config.globalProperties.$router?.currentRoute;
256256
}
257257

258-
function findRouteByName(search: TRouterOptionProps) {
258+
/**
259+
* Find a route from the existing loaded routes.
260+
*
261+
* @param search The route name to search
262+
*/
263+
function findRouteByName(search: string) {
259264
const router = useRouter();
260265
const routes = router.getRoutes();
261266

262267
const findMatches = (children: RouteRecordRaw[]) =>
263268
children.find((it): boolean => {
264-
if (it.name === search.pathName) {
269+
if (it.name === search) {
265270
return true;
266271
} else if (it.children && it.children.length > 0) {
267272
return !!findMatches(it.children);
@@ -271,7 +276,7 @@ function findRouteByName(search: TRouterOptionProps) {
271276
});
272277

273278
return routes.find((it): boolean => {
274-
if (it.name === search.pathName) {
279+
if (it.name === search) {
275280
return true;
276281
} else if (it.children.length > 0) {
277282
return !!findMatches(it.children);
@@ -297,7 +302,7 @@ export function useIsRouteMatch(
297302
return true;
298303
}
299304

300-
const result = findRouteByName(navTarget);
305+
const result = findRouteByName(navTarget.pathName);
301306
if (result) {
302307
return result.path === _route.path || _route.path.startsWith(`${result.path}/`);
303308
}

0 commit comments

Comments
 (0)