-
-
Notifications
You must be signed in to change notification settings - Fork 323
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
[DashboardLayout] Show nested navigation in mini-drawer #4276
base: master
Are you sure you want to change the base?
[DashboardLayout] Show nested navigation in mini-drawer #4276
Conversation
Nice! |
This comment was marked as resolved.
This comment was marked as resolved.
Netlify deploy preview |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really good! Great addition to the feature-set. Some small comments on code.
sx={{ | ||
py: 0, | ||
px: 1, | ||
overflowX: 'hidden', | ||
}} | ||
> | ||
<NavigationListItemButton | ||
selected={isSelected && (!navigationItem.children || isMini)} | ||
selected={ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this could be a useMemo
to prevent having to recalculate on every render
@@ -67,7 +25,9 @@ function buildItemToPathMap(navigation: Navigation): Map<NavigationPageItem, str | |||
|
|||
const visit = (item: NavigationItem, base: string) => { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
<Box | ||
sx={{ | ||
position: 'fixed', | ||
left: 62, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
Initially was just trying to refactor the sidebar navigation in
DashboardLayout
to use the same navigation cache and utilities as thePageContainer
component.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-01-16.at.13.56.19.mov
Also improved selected navigation item tests to cover an extra case.
Inspiration: