Skip to content

Commit 2fd0271

Browse files
committed
Increase NUMERIC_PAD_WIDTH to 15 to fix sorting for 11+ digit numbers
1 parent db5abdd commit 2fd0271

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

src/libs/SidebarUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ function compareStringDates(a: string, b: string): 0 | 1 | -1 {
223223
return 0;
224224
}
225225

226-
const NUMERIC_PAD_WIDTH = 10;
226+
const NUMERIC_PAD_WIDTH = 15;
227227
const DIGIT_SEQUENCE = /\d+/g;
228228

229229
/**
@@ -233,7 +233,7 @@ const sortKeyCache = new Map<string, string>();
233233

234234
/**
235235
* Builds a normalized sort key for fast string comparison using plain < / > operators.
236-
* Lowercases the name and zero-pads numeric segments ("Report 2" → "report 0000000002")
236+
* Lowercases the name and zero-pads numeric segments ("Report 2" → "report 000000000000002")
237237
* so that numeric ordering is preserved without Intl.Collator.
238238
*
239239
* Results are cached at module level so each unique name pays the cost only once.

tests/unit/SidebarUtilsTest.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3371,24 +3371,24 @@ describe('SidebarUtils', () => {
33713371
it('should combine categories in correct order', () => {
33723372
// Given the reports are created
33733373
const pinnedAndGBRReports = [
3374-
{reportID: '1', displayName: 'Pinned 1', sortKey: 'pinned 0000000001'},
3375-
{reportID: '2', displayName: 'Pinned 2', sortKey: 'pinned 0000000002'},
3374+
{reportID: '1', displayName: 'Pinned 1', sortKey: 'pinned 000000000000001'},
3375+
{reportID: '2', displayName: 'Pinned 2', sortKey: 'pinned 000000000000002'},
33763376
];
33773377
const errorReports = [
3378-
{reportID: '3', displayName: 'Error 1', sortKey: 'error 0000000001'},
3379-
{reportID: '4', displayName: 'Error 2', sortKey: 'error 0000000002'},
3378+
{reportID: '3', displayName: 'Error 1', sortKey: 'error 000000000000001'},
3379+
{reportID: '4', displayName: 'Error 2', sortKey: 'error 000000000000002'},
33803380
];
33813381
const draftReports = [
3382-
{reportID: '5', displayName: 'Draft 1', sortKey: 'draft 0000000001'},
3383-
{reportID: '6', displayName: 'Draft 2', sortKey: 'draft 0000000002'},
3382+
{reportID: '5', displayName: 'Draft 1', sortKey: 'draft 000000000000001'},
3383+
{reportID: '6', displayName: 'Draft 2', sortKey: 'draft 000000000000002'},
33843384
];
33853385
const nonArchivedReports = [
3386-
{reportID: '7', displayName: 'Normal 1', sortKey: 'normal 0000000001'},
3387-
{reportID: '8', displayName: 'Normal 2', sortKey: 'normal 0000000002'},
3386+
{reportID: '7', displayName: 'Normal 1', sortKey: 'normal 000000000000001'},
3387+
{reportID: '8', displayName: 'Normal 2', sortKey: 'normal 000000000000002'},
33883388
];
33893389
const archivedReports = [
3390-
{reportID: '9', displayName: 'Archived 1', sortKey: 'archived 0000000001'},
3391-
{reportID: '10', displayName: 'Archived 2', sortKey: 'archived 0000000002'},
3390+
{reportID: '9', displayName: 'Archived 1', sortKey: 'archived 000000000000001'},
3391+
{reportID: '10', displayName: 'Archived 2', sortKey: 'archived 000000000000002'},
33923392
];
33933393

33943394
// When the reports are combined
@@ -3401,10 +3401,10 @@ describe('SidebarUtils', () => {
34013401
it('should filter out reports with undefined reportID', () => {
34023402
// Given the reports are created
34033403
const pinnedAndGBRReports = [
3404-
{reportID: '1', displayName: 'Pinned 1', sortKey: 'pinned 0000000001'},
3404+
{reportID: '1', displayName: 'Pinned 1', sortKey: 'pinned 000000000000001'},
34053405
{reportID: undefined, displayName: 'Invalid', sortKey: 'invalid'},
34063406
];
3407-
const errorReports = [{reportID: '2', displayName: 'Error 1', sortKey: 'error 0000000001'}];
3407+
const errorReports = [{reportID: '2', displayName: 'Error 1', sortKey: 'error 000000000000001'}];
34083408
const draftReports: Array<{reportID?: string; displayName: string; sortKey: string; lastVisibleActionCreated?: string}> = [];
34093409
const nonArchivedReports: Array<{reportID?: string; displayName: string; sortKey: string; lastVisibleActionCreated?: string}> = [];
34103410
const archivedReports: Array<{reportID?: string; displayName: string; sortKey: string; lastVisibleActionCreated?: string}> = [];

0 commit comments

Comments
 (0)