[DashboardLayout] Show nested navigation in mini-drawer#4276
[DashboardLayout] Show nested navigation in mini-drawer#4276apedroferreira merged 16 commits intomui:masterfrom apedroferreira:refactor-nav-selected-item
Conversation
|
Nice! |
This comment was marked as resolved.
This comment was marked as resolved.
Netlify deploy preview |
bharatkashyap
left a comment
There was a problem hiding this comment.
Looks really good! Great addition to the feature-set. Some small comments on code.
| > | ||
| <NavigationListItemButton | ||
| selected={isSelected && (!navigationItem.children || isMini)} | ||
| selected={ |
There was a problem hiding this comment.
Might be helpful to add some comments to explain the thinking behind the really long ternaries
|
|
||
| if (isSelected && !selectedItemId) { | ||
| selectedItemId = navigationItemId; | ||
| let nestedNavigationCollapseSx: SxProps<Theme> = { display: 'none' }; |
There was a problem hiding this comment.
Seems like this could be a useMemo to prevent having to recalculate on every render
| if (isPageItem(item)) { | ||
| const path = `${base}${item.segment ? `/${item.segment}` : ''}` || '/'; | ||
| const path = | ||
| `${base.startsWith('/') ? base : `/${base}`}${base && base !== '/' && item.segment ? '/' : ''}${item.segment || ''}` || |
There was a problem hiding this comment.
Similar comment about comments being helpful on really long ternaries. Even though this one seems relatively straightforward, a comment helps bolt down the original intent instead of having to guess/derive
| return hasSelectedNavigationChildren(navigation, nestedItem, activePagePath); | ||
| } | ||
|
|
||
| return activePagePath === getItemPath(navigation, nestedItem); |
There was a problem hiding this comment.
To be sure, does this function work in cases where the nested navigation items are supplied via regex patterns? I might be missing something, but seems like the earlier function was checking for a navigationItem.pattern case and testing the path against the regex pattern in case it existed but I can't seem to find an analogous case here
There was a problem hiding this comment.
I believe the activePagePath that goes here as a parameter already accounts for pattern matching with the logic in the useActivePage hook. I'll check again just to be sure.
So the behavior should be that pattern matching in children items works, but only under the segments in the parent items. If the parent also has a pattern, that pattern in the parent will probably be ignored in these cases and I think that's probably the way it should work.
| <Box | ||
| sx={{ | ||
| position: 'fixed', | ||
| left: 62, |
There was a problem hiding this comment.
Is there no avoidable way to hard code the left and pl values here? I could be wrong but this might create a future bug if we make the size of the mini sidebar configurable - perhaps we can link these values to that constant (if indeed they derive from it)
|
Related a little to this item... If you have a navigation structure that a PAGE item also has children, when the navigation drawer is open (Wide), you cant actually navigate to the page, because clicking on it expands to make the children visible. However, when the navigation drawer is closed (Narrow), you get taken to the page when you click on the item. { |
Hey, I know, that behavior will change once this PR is merged. |
|
Didn't want to abandon this old PR so addressed review suggestions + improved mini bar design as the previous one here wasn't great. |
|
What needs to happen to get this change released - its good work - the menu bar is so much more functional when minimised!On 13 Mar 2025, at 18:41, Pedro Ferreira ***@***.***> wrote:
Didn't want to abandon this old PR so fixed what made sense from the review suggestions + improved mini bar design as the previous one here wasn't great.
Updated the video above with the new mini bar design.—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: ***@***.***>
apedroferreira left a comment (mui/toolpad#4276)
Didn't want to abandon this old PR so fixed what made sense from the review suggestions + improved mini bar design as the previous one here wasn't great.
Updated the video above with the new mini bar design.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: ***@***.***>
|
|
I'll merge this one soon if it's good with everyone! |
Yes, great |
Initially was just trying to refactor the sidebar navigation in
DashboardLayoutto use the same navigation cache and utilities as thePageContainercomponent.But this required adding nested navigation to the sidebar for consistency with the warnings we show when there are duplicated navigation items, because the navigation links should match in all variants of the sidebar:
Screen.Recording.2025-03-13.at.18.08.48.mov
Also improved selected navigation item tests to cover an extra case.
Inspiration: