Enhance DashboardSidebar Item Mapping Logic
- Updated the mapItemsRecursively function to accept an additional parameter for controlling tooltip visibility on collapsed items, improving user experience. - Adjusted the recursive mapping of children items to ensure tooltips are displayed correctly based on the new parameter, enhancing clarity in the sidebar's item representation.
This commit is contained in:
parent
a67a86f185
commit
fedc8ba5fa
@ -75,17 +75,19 @@ const DashboardSidebar = ({
|
||||
}
|
||||
|
||||
// Recursive function to map items and their children
|
||||
const mapItemsRecursively = (items) => {
|
||||
const mapItemsRecursively = (items, showCollapsedTooltip = true) => {
|
||||
return items.map((item) => {
|
||||
if (item?.type === 'divider') {
|
||||
return item
|
||||
}
|
||||
|
||||
console.log(item)
|
||||
|
||||
const icon = item.icon || getSidebarIconNode(item.iconKey)
|
||||
const mappedItem = {
|
||||
key: item.key,
|
||||
icon:
|
||||
collapsed && !isMobile ? (
|
||||
collapsed && !isMobile && showCollapsedTooltip && !item.children ? (
|
||||
<CollapsedItemIcon title={item.label} icon={icon} />
|
||||
) : (
|
||||
icon
|
||||
@ -100,7 +102,7 @@ const DashboardSidebar = ({
|
||||
|
||||
// Recursively map children if they exist
|
||||
if (item?.children && Array.isArray(item.children)) {
|
||||
mappedItem.children = mapItemsRecursively(item.children)
|
||||
mappedItem.children = mapItemsRecursively(item.children, false)
|
||||
}
|
||||
|
||||
return mappedItem
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user