Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Sidebar's parent items "navigable" #1042

Open
JBBianchi opened this issue Feb 12, 2025 · 0 comments
Open

Make Sidebar's parent items "navigable" #1042

JBBianchi opened this issue Feb 12, 2025 · 0 comments

Comments

@JBBianchi
Copy link

Hello,

I’d like to request a feature for the Sidebar component.

Current Behavior:

  • A SidebarItem can either be a parent (has children) or a leaf (no children).
  • A leaf is rendered as a NavLink with an href attribute, making it a clickable link.
  • A parent is also rendered as a NavLink but functions as a toggle (role="button") to expand or collapse its child items.

Proposed Behavior:

If a Href has been provided in the parent:

  • If the parent is collapsed, clicking on it should expand the group AND navigate to the defined Href
  • If the parent is expanded, clicking should only toggle the expansion state (=collapsed).

Example Implementation:

private void ToggleNavItemGroup() {
  if (!navitemGroupExpanded && !string.IsNullOrEmpty(Href)) {
    NavigationManager.NavigateTo(Href, false);
  }
  navitemGroupExpanded = !navitemGroupExpanded;
}

Use case:

Consider this sidebar structure:

|__ Products (/products)
  |_ List (/products)
  |_ New (/products/new)

When a user clicks "Products", it should expand the group and navigate to /products by default (showing the list of products). This behavior improves usability by reducing an unnecessary click when the parent item itself is a valid navigation destination.

Would love to hear your thoughts on this! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant