Skip to content

Commit 6c2d911

Browse files
authored
Merge pull request #191 from oss-slu/fix/alphabetize-repo-dropdown
Fix: Alphabetize Repo Dropdown
2 parents 85132fa + 215707e commit 6c2d911

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

Frontend/src/features/team-stats/components/teamStatsSidebar.jsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ const TeamStatsSidebar = ({
4242
<div className="sidebar-section">
4343
<label className="sidebar-label">Team</label>
4444
<select className="sidebar-select" value={selectedTeam} onChange={(e) => setSelectedTeam(e.target.value)}>
45-
{TEAMS.map((t, index) => <option key={`team-${index}`} value={t}>{t}</option>)}
45+
{[...TEAMS]
46+
.sort((a, b) => a.localeCompare(b)) // Sort alphabetically
47+
.map((t, index) => (
48+
<option key={`team-${index}`} value={t}>
49+
{t}
50+
</option>
51+
))}
4652
</select>
4753
</div>
4854
)}
@@ -59,7 +65,20 @@ const TeamStatsSidebar = ({
5965
setSelectedUser("all");
6066
}}
6167
>
62-
{TEAMS.map((t, index) => <option key={`repo-${index}`} value={t}>{t}</option>)}
68+
{[...TEAMS]
69+
.sort((a, b) => {
70+
// Keeping "All Teams" at the top
71+
if (a === "All Teams") return -1;
72+
if (b === "All Teams") return 1;
73+
74+
// Sort the rest alphabetically
75+
return a.localeCompare(b);
76+
})
77+
.map((t, index) => (
78+
<option key={`repo-${index}`} value={t}>
79+
{t}
80+
</option>
81+
))}
6382
</select>
6483
</div>
6584

0 commit comments

Comments
 (0)