Breadcrumbs: Don't add breadcrumb for the current tab (#68230)

Breadcrumbs: Don't add breadcrumbs for the current tab
This commit is contained in:
Torkel Ödegaard 2023-05-11 15:16:42 +02:00 committed by GitHub
parent 43be4f095a
commit c9ce1a28c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 29 deletions

View File

@ -144,22 +144,5 @@ describe('breadcrumb utils', () => {
{ text: 'My page', href: '/my-page' },
]);
});
it('Should add breadcrumbs for child pages that have not set parentItem', () => {
const pageNav: NavModelItem = {
text: 'My page',
url: '/my-page',
children: [
{ text: 'A', url: '/a', active: true },
{ text: 'B', url: '/b' },
],
};
expect(buildBreadcrumbs(mockHomeNav, pageNav, mockHomeNav)).toEqual([
{ text: 'Home', href: '/home' },
{ text: 'My page', href: '/my-page' },
{ text: 'A', href: '/a' },
]);
});
});
});

View File

@ -30,19 +30,8 @@ export function buildBreadcrumbs(sectionNav: NavModelItem, pageNav?: NavModelIte
}
if (pageNav) {
if (pageNav.url && pageNav.children) {
const child = pageNav.children.find((child) => child.active);
if (child) {
addCrumbs(child);
// Some pages set up children but they are not connected to parent pageNav
if (child.parentItem !== pageNav) {
addCrumbs(pageNav);
}
}
} else {
addCrumbs(pageNav);
}
}
addCrumbs(sectionNav);