Navigation: correctly mark a MegaMenuItem as active if it has active children (#76944)

correctly mark a MegaMenuItem as active if it has active children
This commit is contained in:
Ashley Harrison 2023-10-23 10:55:25 +01:00 committed by GitHub
parent 120247667b
commit f9a89e5cd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,8 +22,8 @@ const MAX_DEPTH = 2;
export function MegaMenuItem({ link, activeItem, level = 0, onClick }: Props) {
const FeatureHighlightWrapper = link.highlightText ? FeatureHighlight : React.Fragment;
const isActive = link === activeItem;
const hasActiveChild = hasChildMatch(link, activeItem);
const isActive = link === activeItem || (level === MAX_DEPTH && hasActiveChild);
const [sectionExpanded, setSectionExpanded] =
useLocalStorage(`grafana.navigation.expanded[${link.text}]`, false) ?? Boolean(hasActiveChild);
const showExpandButton = level < MAX_DEPTH && Boolean(linkHasChildren(link) || link.emptyMessage);