diff --git a/public/app/core/components/AppChrome/MegaMenu/utils.ts b/public/app/core/components/AppChrome/MegaMenu/utils.ts index e75fe898796..2f180c5e674 100644 --- a/public/app/core/components/AppChrome/MegaMenu/utils.ts +++ b/public/app/core/components/AppChrome/MegaMenu/utils.ts @@ -8,13 +8,12 @@ import { getFooterLinks } from '../../Footer/Footer'; import { HelpModal } from '../../help/HelpModal'; export const enrichHelpItem = (helpItem: NavModelItem) => { - const onOpenShortcuts = () => { - appEvents.publish(new ShowModalReactEvent({ component: HelpModal })); - }; - let menuItems = helpItem.children || []; if (helpItem.id === 'help') { + const onOpenShortcuts = () => { + appEvents.publish(new ShowModalReactEvent({ component: HelpModal })); + }; helpItem.children = [ ...menuItems, ...getFooterLinks(), diff --git a/public/app/core/components/AppChrome/TopBar/TopSearchBar.tsx b/public/app/core/components/AppChrome/TopBar/TopSearchBar.tsx index 6ec678802da..7843299f910 100644 --- a/public/app/core/components/AppChrome/TopBar/TopSearchBar.tsx +++ b/public/app/core/components/AppChrome/TopBar/TopSearchBar.tsx @@ -26,7 +26,8 @@ export const TopSearchBar = React.memo(function TopSearchBar() { const navIndex = useSelector((state) => state.navIndex); const location = useLocation(); - const helpNode = enrichHelpItem(cloneDeep(navIndex['help'])); + const helpNode = cloneDeep(navIndex['help']); + const enrichedHelpNode = helpNode ? enrichHelpItem(helpNode) : undefined; const profileNode = navIndex['profile']; let homeUrl = config.appSubUrl || '/'; @@ -49,8 +50,8 @@ export const TopSearchBar = React.memo(function TopSearchBar() { - {helpNode && ( - } placement="bottom-end"> + {enrichedHelpNode && ( + } placement="bottom-end"> )}