blazorbootstrap icon indicating copy to clipboard operation
blazorbootstrap copied to clipboard

Bug / Feature Request: Expand Sidebar NavItems with ParentId on Initial Load

Open Torchok19081986 opened this issue 5 months ago • 1 comments

Currently, when using <Sidebar> with a DataProvider, NavItems that have a ParentId are not expanded by default on initial load – only the top-level items are visible. This is confusing for users, especially when a sub-item is the current active route, but its parent menu is collapsed.

There seems to be no property or method to control the expanded/collapsed state of sidebar groups on load, or to programmatically expand specific NavItems based on the current route.

✅ Expected Behavior When a sub-NavItem is active (i.e., its route matches the current URL), its parent group should be automatically expanded.

Alternatively, a way to control the expanded state (e.g., via IsExpanded, or callback in SidebarDataProvider) should be available.

new NavItem
{
    Id = "parent1",
    Text = "Parent Menu",
    IconName = IconName.Folder,
    Url = null,
},
new NavItem
{
    ParentId = "parent1",
    Text = "Child Page",
    Url = "/childpage"
}

If the current page is /childpage, the menu is collapsed and "Child Page" is hidden unless the user clicks to expand "Parent Menu".

Suggested Solutions Automatically expand parent groups if any of their children is Active=true.

Add an IsExpanded property to NavItem.

Provide a callback/hook during SidebarDataProvider execution to allow logic-based expansion.

Torchok19081986 avatar Aug 08 '25 07:08 Torchok19081986

@Torchok19081986 Thank you for using BlazorBootstrap. We will review the behaviour.

gvreddy04 avatar Aug 14 '25 12:08 gvreddy04