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

Show parent Nav as active as well #4538

Open
gazi786 opened this issue Dec 13, 2024 Discussed in #4534 · 7 comments
Open

Show parent Nav as active as well #4538

gazi786 opened this issue Dec 13, 2024 Discussed in #4534 · 7 comments
Labels
component: layout This is the name of the generic UI component, not the React module! new feature New feature or request scope: toolpad-core Abbreviated to "core" waiting for 👍 Waiting for upvotes

Comments

@gazi786
Copy link

gazi786 commented Dec 13, 2024

Discussed in #4534

Originally posted by gazi786 December 12, 2024
If a dependent route is selected how can I make the parent nav active as well. That is have the Mui-selected class attached to the parent node as well.

Also goes in a parent link has a grandchild all three should be shown active.

image

This is more of a feature request rather then an issue.

Search keywords:

@github-actions github-actions bot added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 13, 2024
@bharatkashyap bharatkashyap added new feature New feature or request component: layout This is the name of the generic UI component, not the React module! and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Dec 13, 2024
@Janpot
Copy link
Member

Janpot commented Dec 13, 2024

I feel like this could probably benefit from a bit more discussion and benchmarking before we implement a solution? Personally I'm not fully convinced that making this configurable should be part of Toolpad public API. It feels like for this level of customizability, a slot for the whole navigation menu allows you to write a custom version that behaves exactly as you want without burdening the library with extra complexity.

@gazi786
Copy link
Author

gazi786 commented Dec 13, 2024

Agreed... a slotProp to assign the Mui-selected class to the parents of the related selected child. Since the AppProvider's NavigationContext renders the navigation, I have tried to push a state through redux to the AppProvider but have been unsuccessful at the moment.

Still a learning curve for me.

The DashboardLayout component controls many actions for the dashboard. I'm trying to look into how the side nav gets rendered.

@gazi786
Copy link
Author

gazi786 commented Dec 16, 2024

Since the navigation is recursively rendered using the component:

<DashboardSidebarSubNavigation
        subNavigation={navigation}
        onLinkClick={handleNavigationLinkClick}
        isMini={isMini}
        isFullyExpanded={isNavigationFullyExpanded}
        hasDrawerTransitions={hasDrawerTransitions}
        selectedItemId={selectedItemIdRef.current}
      />

in the DashboardLayout component...

So, would it be easy to add a prop, say, isParentActive, that adds the Mui-selected class to the Parent or even use the selectedItemId reference?

@prakhargupta1 prakhargupta1 added scope: toolpad-core Abbreviated to "core" waiting for 👍 Waiting for upvotes labels Dec 16, 2024
@prakhargupta1
Copy link
Member

I checked a few tools and docs that have nested navigation and found that most of them don't show the parent as selected. Two of those who do this:

  1. https://e2b.dev/docs
  2. Google Analytics (but Gmail doesn't :p)
Screenshot 2024-12-17 at 1 06 13 PM

As per the linked discussion, @gazi786 managed to resolve this for their use case. I have added 'waiting for upvotes' label to see if more users want this.

@gazi786
Copy link
Author

gazi786 commented Dec 17, 2024

@prakhargupta1 thats what I have checked.. Alot of the apps don't show the parent Nav active. It usually suits when we working with top navigation.

If we get a good number of feedback perhaps we can include it in a later release.

Thanks for the awesome feedback and support.

@prakhargupta1
Copy link
Member

prakhargupta1 commented Dec 17, 2024

Thanks for the awesome feedback and support.

@gazi786 Thanks for explaining the issue well. From the screenshots you shared, I can see that the dashboard is coming along well. In case you need any help or discuss a problem, feel free to schedule a call.

@gazi786
Copy link
Author

gazi786 commented Dec 17, 2024

Thanks mate will do...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: layout This is the name of the generic UI component, not the React module! new feature New feature or request scope: toolpad-core Abbreviated to "core" waiting for 👍 Waiting for upvotes
Projects
None yet
Development

No branches or pull requests

4 participants