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 · 3 comments
Open

Show parent Nav as active as well #4538

gazi786 opened this issue Dec 13, 2024 Discussed in #4534 · 3 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"

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 the scope: toolpad-core Abbreviated to "core" label Dec 16, 2024
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"
Projects
None yet
Development

No branches or pull requests

4 participants