diff --git a/public/app/core/components/Breadcrumbs/utils.test.ts b/public/app/core/components/Breadcrumbs/utils.test.ts index 8302d42c0ca..bc76522cb2b 100644 --- a/public/app/core/components/Breadcrumbs/utils.test.ts +++ b/public/app/core/components/Breadcrumbs/utils.test.ts @@ -120,31 +120,6 @@ describe('breadcrumb utils', () => { ]); }); - it('does not match the home nav if the editview param is different', () => { - const pageNav: NavModelItem = { - text: 'My page', - url: '/my-page', - parentItem: { - text: 'My parent page', - url: '/home?orgId=1&editview=settings', - }, - }; - const sectionNav: NavModelItem = { - text: 'My section', - url: '/my-section', - parentItem: { - text: 'My parent section', - url: '/my-parent-section', - }, - }; - expect(buildBreadcrumbs(sectionNav, pageNav, mockHomeNav)).toEqual([ - { text: 'My parent section', href: '/my-parent-section' }, - { text: 'My section', href: '/my-section' }, - { text: 'My parent page', href: '/home?orgId=1&editview=settings' }, - { text: 'My page', href: '/my-page' }, - ]); - }); - it('does ignore duplicates', () => { const pageNav: NavModelItem = { text: 'My page', diff --git a/public/app/core/components/Breadcrumbs/utils.ts b/public/app/core/components/Breadcrumbs/utils.ts index fa88667efc5..c5c66a0c922 100644 --- a/public/app/core/components/Breadcrumbs/utils.ts +++ b/public/app/core/components/Breadcrumbs/utils.ts @@ -13,21 +13,9 @@ export function buildBreadcrumbs(sectionNav: NavModelItem, pageNav?: NavModelIte } // construct the URL to match - // we want to ignore query params except for the editview query param const urlParts = node.url?.split('?') ?? ['', '']; let urlToMatch = urlParts[0]; - const urlSearchParams = new URLSearchParams(urlParts[1]); - - if (urlSearchParams.has('editview')) { - urlToMatch += `?editview=${urlSearchParams.get('editview')}`; - } - - // This enabled app plugins to control breadcrumbs of their root pages - const isSamePathAsLastBreadcrumb = urlToMatch.length > 0 && lastPath === urlToMatch; - // Remember this path for the next breadcrumb - lastPath = urlToMatch; - // Check if we found home/root if if so return early if (homeNav && urlToMatch === homeNav.url) { crumbs.unshift({ text: homeNav.text, href: node.url ?? '' }); @@ -35,6 +23,11 @@ export function buildBreadcrumbs(sectionNav: NavModelItem, pageNav?: NavModelIte return; } + // This enabled app plugins to control breadcrumbs of their root pages + const isSamePathAsLastBreadcrumb = urlToMatch.length > 0 && lastPath === urlToMatch; + // Remember this path for the next breadcrumb + lastPath = urlToMatch; + if (!node.hideFromBreadcrumbs && !isSamePathAsLastBreadcrumb) { crumbs.unshift({ text: node.text, href: node.url ?? '' }); }