fix: address PR review comments

- Fix branch fallback logic: use nullish coalescing (??) instead of || to handle empty strings correctly (empty string represents unassigned features, not main branch)
- Refactor branchCardCounts calculation: use reduce instead of forEach for better conciseness and readability
- Fix badge semantics in BranchAutocomplete: check branchCardCounts !== undefined first to ensure numeric badges (including 0) only appear when actual count data exists, while 'default' is reserved for when count data is unavailable
This commit is contained in:
Cody Seibert
2025-12-18 17:53:37 -05:00
parent f0bea76141
commit 81d631ea72
2 changed files with 6 additions and 10 deletions

View File

@@ -33,8 +33,8 @@ export function BranchAutocomplete({
return Array.from(branchSet).map((branch) => {
const cardCount = branchCardCounts?.[branch];
// Show card count if available, otherwise show "default" for main branch only
const badge = cardCount !== undefined
? String(cardCount)
const badge = branchCardCounts !== undefined
? String(cardCount ?? 0)
: branch === "main"
? "default"
: undefined;

View File

@@ -272,17 +272,13 @@ export function BoardView() {
// Calculate unarchived card counts per branch
const branchCardCounts = useMemo(() => {
const counts: Record<string, number> = {};
// Count unarchived features (status !== "completed") per branch
hookFeatures.forEach((feature) => {
return hookFeatures.reduce((counts, feature) => {
if (feature.status !== "completed") {
const branch = feature.branchName || "main";
const branch = feature.branchName ?? "main";
counts[branch] = (counts[branch] || 0) + 1;
}
});
return counts;
return counts;
}, {} as Record<string, number>);
}, [hookFeatures]);
// Custom collision detection that prioritizes columns over cards