ensure the first item in the sectionnav is always the section root (#56815)

This commit is contained in:
Ashley Harrison 2022-10-12 17:02:31 +01:00 committed by GitHub
parent 8846778f9b
commit 61fd369b3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 4 deletions

View File

@ -26,7 +26,7 @@ export function SectionNav({ model, isExpanded }: Props) {
>
<CustomScrollbar showScrollIndicators>
<div className={styles.items} role="tablist">
<SectionNavItem item={model.main} />
<SectionNavItem item={model.main} isSectionRoot />
</div>
</CustomScrollbar>
</nav>

View File

@ -4,19 +4,18 @@ import React from 'react';
import { GrafanaTheme2, NavModelItem } from '@grafana/data';
import { selectors } from '@grafana/e2e-selectors';
import { useStyles2, Icon } from '@grafana/ui';
import { HOME_NAV_ID } from 'app/core/reducers/navModel';
import { getNavTitle } from '../NavBar/navBarItem-translations';
export interface Props {
item: NavModelItem;
isSectionRoot?: boolean;
}
export function SectionNavItem({ item }: Props) {
export function SectionNavItem({ item, isSectionRoot = false }: Props) {
const styles = useStyles2(getStyles);
const children = item.children?.filter((x) => !x.hideFromTabs);
const isSectionRoot = item.parentItem?.id === HOME_NAV_ID;
const hasActiveChild = Boolean(children?.length && children.find((x) => x.active));
// If first root child is a section skip the bottom margin (as sections have top margin already)