Skip to content

Commit 5a995df

Browse files
committed
The default branch should always come first in the branch selector
1 parent 68cc0fc commit 5a995df

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

apps/array/src/renderer/features/task-detail/components/BranchSelect.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export function BranchSelect({
144144
}
145145
};
146146

147-
// filter branches based on search query
147+
// filter and sort branches based on search query
148148
const filteredBranches = useMemo(() => {
149149
let result = branches;
150150
if (searchQuery.trim()) {
@@ -153,8 +153,14 @@ export function BranchSelect({
153153
branch.toLowerCase().includes(query),
154154
);
155155
}
156+
// Sort alphabetically, but default branch always comes first
157+
result = [...result].sort((a, b) => {
158+
if (a === defaultBranch) return -1;
159+
if (b === defaultBranch) return 1;
160+
return a.localeCompare(b);
161+
});
156162
return result.slice(0, MAX_DISPLAYED_BRANCHES);
157-
}, [branches, searchQuery]);
163+
}, [branches, searchQuery, defaultBranch]);
158164

159165
const hasMoreBranches =
160166
branches.length > MAX_DISPLAYED_BRANCHES && !searchQuery;

0 commit comments

Comments
 (0)