From e76d33e97df7195b521c13df22dde5ff05a99376 Mon Sep 17 00:00:00 2001 From: Ivan Shmidt Date: Sat, 22 Aug 2020 10:37:02 +0200 Subject: [PATCH] fix: move catch-all route out of loop --- .../src/components/EntityPageTabs/EntityPageTabs.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/catalog/src/components/EntityPageTabs/EntityPageTabs.tsx b/plugins/catalog/src/components/EntityPageTabs/EntityPageTabs.tsx index f4f9308669..2053c05b91 100644 --- a/plugins/catalog/src/components/EntityPageTabs/EntityPageTabs.tsx +++ b/plugins/catalog/src/components/EntityPageTabs/EntityPageTabs.tsx @@ -38,6 +38,7 @@ export const EntityPageTabs = ({ children }: { children: React.ReactNode }) => { const tabs: Tab[] = []; const params = useParams(); const navigate = useNavigate(); + React.Children.forEach(children, child => { if (!React.isValidElement(child)) { // Skip conditionals resolved to falses/nulls/undefineds etc @@ -54,11 +55,14 @@ export const EntityPageTabs = ({ children }: { children: React.ReactNode }) => { id: pathAndId, label: (child as JSX.Element).props.title, }); - routes.push({ - path: '/*', - element: , - }); }); + + // Add catch-all for incorrect sub-routes + routes.push({ + path: '/*', + element: , + }); + const [matchedRoute] = matchRoutes(routes as RouteObject[], `/${params['*']}`) ?? []; const selectedIndex = getSelectedIndex(matchedRoute, tabs);