mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Navigation: Fix wrong active item shown when parent is bookmarked (#94478)
This commit is contained in:
parent
55d970ef9a
commit
322dccdb4d
@ -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');
|
||||
});
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user