fixed route resolving

Signed-off-by: Alex Rybchenko <arybchenko@box.com>
This commit is contained in:
Alex Rybchenko
2021-10-27 13:08:57 +02:00
parent 52ebd2d3a0
commit 021986e8a3
3 changed files with 16 additions and 3 deletions
+6
View File
@@ -0,0 +1,6 @@
---
'@backstage/core-components': patch
'@backstage/plugin-catalog': patch
---
fixed route resolving
@@ -33,9 +33,14 @@ export function useSelectedSubRoute(subRoutes: SubRoute[]): {
element: children,
}));
const element = useRoutes(routes) ?? subRoutes[0].children;
// TODO: remove once react-router updated
const sortedRoutes = routes.sort((a, b) =>
b.path.slice(0, -2).localeCompare(a.path.slice(0, -2)),
);
const [matchedRoute] = matchRoutes(routes, `/${params['*']}`) ?? [];
const element = useRoutes(sortedRoutes) ?? subRoutes[0].children;
const [matchedRoute] = matchRoutes(sortedRoutes, `/${params['*']}`) ?? [];
const foundIndex = matchedRoute
? subRoutes.findIndex(t => `${t.path}/*` === matchedRoute.route.path)
: 0;
@@ -200,7 +200,9 @@ export const EntityLayout = ({
tabProps: props.tabProps,
},
];
}),
})
// TODO: remove once react-router updated
.sort((a, b) => b.path.localeCompare(a.path)),
[entity],
);