diff --git a/public/app/core/components/AppChrome/MegaMenu/utils.test.ts b/public/app/core/components/AppChrome/MegaMenu/utils.test.ts index 0a99bffd6b3..ea5a289bd95 100644 --- a/public/app/core/components/AppChrome/MegaMenu/utils.test.ts +++ b/public/app/core/components/AppChrome/MegaMenu/utils.test.ts @@ -5,6 +5,22 @@ import { enrichHelpItem, getActiveItem, findByUrl } from './utils'; const starredDashboardUid = 'foo'; const mockNavTree: NavModelItem[] = [ + { + text: 'Bookmarks', + url: '/bookmarks', + id: 'bookmarks', + children: [ + { + text: 'Item with children', + url: '/itemWithChildren', + id: 'item-with-children', + parentItem: { + text: 'Bookmarks', + id: 'bookmarks', + }, + }, + ], + }, { text: 'Item', url: '/item', @@ -112,6 +128,10 @@ describe('getActiveItem', () => { const mockPage: NavModelItem = { text: 'Some child page', id: 'child', + parentItem: { + text: 'Item with children', + id: 'item-with-children', + }, }; expect(getActiveItem(mockNavTree, mockPage)?.id).toEqual('child'); }); diff --git a/public/app/core/components/AppChrome/MegaMenu/utils.ts b/public/app/core/components/AppChrome/MegaMenu/utils.ts index ab41e68dee6..e8864399a0c 100644 --- a/public/app/core/components/AppChrome/MegaMenu/utils.ts +++ b/public/app/core/components/AppChrome/MegaMenu/utils.ts @@ -98,7 +98,9 @@ export const getActiveItem = ( } } - if (parentItem) { + // Do not search for the parent in the bookmarks section + const isInBookmarksSection = navTree[0]?.parentItem?.id === 'bookmarks'; + if (parentItem && !isInBookmarksSection) { return getActiveItem(navTree, parentItem); }