Skip to content

Commit 1f85c8b

Browse files
committed
fix: lowercase attendees before comparing so joined string matches pill order
1 parent 9c0c801 commit 1f85c8b

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/libs/TransactionUtils/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1220,8 +1220,9 @@ function getAttendeesDisplayCollator(): Intl.Collator {
12201220
*/
12211221
function getAttendeesListDisplayString(attendees: Attendee[]): string {
12221222
const collator = getAttendeesDisplayCollator();
1223+
// Lowercase to match sortAlphabetically (the pill sort) so joined string and pill order never disagree on case.
12231224
return [...attendees]
1224-
.sort((a, b) => collator.compare(a.displayName ?? a.login ?? '', b.displayName ?? b.login ?? ''))
1225+
.sort((a, b) => collator.compare((a.displayName ?? a.login ?? '').toLowerCase(), (b.displayName ?? b.login ?? '').toLowerCase()))
12251226
.map((item) => item.displayName ?? item.login)
12261227
.join(', ');
12271228
}

tests/unit/TransactionUtilsTest.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,6 +1408,14 @@ describe('TransactionUtils', () => {
14081408
expect(TransactionUtils.getAttendeesListDisplayString(attendees)).toBe('User 9, User 10');
14091409
});
14101410

1411+
it('compares case-insensitively so the joined string matches pill order', () => {
1412+
const attendees: Attendee[] = [
1413+
{email: 'b@x.com', displayName: 'Bob', avatarUrl: '', login: 'b@x.com'},
1414+
{email: 'a@x.com', displayName: 'alice', avatarUrl: '', login: 'a@x.com'},
1415+
];
1416+
expect(TransactionUtils.getAttendeesListDisplayString(attendees)).toBe('alice, Bob');
1417+
});
1418+
14111419
it('returns empty string for empty array', () => {
14121420
expect(TransactionUtils.getAttendeesListDisplayString([])).toBe('');
14131421
});

0 commit comments

Comments
 (0)