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:
Tom Butcher 2026-08-21 19:09:40 +01:00
parent a67a86f185
commit fedc8ba5fa

View File

@ -75,17 +75,19 @@ const DashboardSidebar = ({
} }
// Recursive function to map items and their children // Recursive function to map items and their children
const mapItemsRecursively = (items) => { const mapItemsRecursively = (items, showCollapsedTooltip = true) => {
return items.map((item) => { return items.map((item) => {
if (item?.type === 'divider') { if (item?.type === 'divider') {
return item return item
} }
console.log(item)
const icon = item.icon || getSidebarIconNode(item.iconKey) const icon = item.icon || getSidebarIconNode(item.iconKey)
const mappedItem = { const mappedItem = {
key: item.key, key: item.key,
icon: icon:
collapsed && !isMobile ? ( collapsed && !isMobile && showCollapsedTooltip && !item.children ? (
<CollapsedItemIcon title={item.label} icon={icon} /> <CollapsedItemIcon title={item.label} icon={icon} />
) : ( ) : (
icon icon
@ -100,7 +102,7 @@ const DashboardSidebar = ({
// Recursively map children if they exist // Recursively map children if they exist
if (item?.children && Array.isArray(item.children)) { if (item?.children && Array.isArray(item.children)) {
mappedItem.children = mapItemsRecursively(item.children) mappedItem.children = mapItemsRecursively(item.children, false)
} }
return mappedItem return mappedItem