Skip to content

Commit 1979f4c

Browse files
authored
fix(desktop): v2 sidebar section count reflects visually grouped workspaces (#3544)
Ungrouped workspaces that render after a section header are already visually grouped with that section (shared accent color, collapse together) and get committed into it on next drag. The count, however, was reading section.workspaces which only included workspaces whose DB sectionId already matched — so a freshly created section showed "(0)" while the user sees N workspaces beneath it. Reparent those workspaces into section.workspaces in the data layer so the count matches the visual grouping and DnD commit behavior.
1 parent 0b62387 commit 1979f4c

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/hooks/useDashboardSidebarData

apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/hooks/useDashboardSidebarData/useDashboardSidebarData.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,31 @@ export function useDashboardSidebarData() {
324324
sectionMap: _sectionMap,
325325
...sidebarProject
326326
} = resolvedProject;
327-
sidebarProject.children = childEntries
327+
328+
const sortedChildren = childEntries
328329
.sort((left, right) => left.tabOrder - right.tabOrder)
329330
.map(({ child }) => child);
331+
332+
// Ungrouped workspaces rendered after a section header are visually
333+
// grouped with that section (shared accent, collapse-together) and will
334+
// be committed into it on next DnD. Reparent them here so section counts
335+
// match what the user sees.
336+
const children: DashboardSidebarProjectChild[] = [];
337+
let currentSection: DashboardSidebarSection | null = null;
338+
for (const child of sortedChildren) {
339+
if (child.type === "section") {
340+
currentSection = child.section;
341+
children.push(child);
342+
} else if (currentSection) {
343+
currentSection.workspaces.push({
344+
...child.workspace,
345+
accentColor: currentSection.color,
346+
});
347+
} else {
348+
children.push(child);
349+
}
350+
}
351+
sidebarProject.children = children;
330352
return [sidebarProject];
331353
});
332354
}, [

0 commit comments

Comments
 (0)