Skip to content

Commit 659ca5e

Browse files
committed
Fix NaN comparator skipping tiebreaker in project sorting
When both projects lack timestamps and have no threads, getProjectSortTimestamp returns NEGATIVE_INFINITY for both. Subtracting NEGATIVE_INFINITY - NEGATIVE_INFINITY yields NaN, and since NaN !== 0 is true, the comparator returned NaN instead of falling through to the name/id tiebreaker. Add Number.isNaN guard to the condition.
1 parent d9ef0ca commit 659ca5e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

apps/web/src/components/Sidebar.logic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ export function sortProjectsForSidebar<TProject extends SidebarProject, TThread
270270
const byTimestamp =
271271
getProjectSortTimestamp(right, threadsByProjectId.get(right.id) ?? [], sortOrder) -
272272
getProjectSortTimestamp(left, threadsByProjectId.get(left.id) ?? [], sortOrder);
273-
if (byTimestamp !== 0) return byTimestamp;
273+
if (byTimestamp !== 0 && !Number.isNaN(byTimestamp)) return byTimestamp;
274274
return left.name.localeCompare(right.name) || left.id.localeCompare(right.id);
275275
});
276276
}

0 commit comments

Comments
 (0)