Compare commits

...
Author SHA1 Message Date
Sonarly Claude CodeandClaude Opus 4.6 dcd8ddb86f fix: resolve TypeError when sorting relations table by App column
The isCustom field is a boolean but was declared as fieldType 'string' in
the table metadata. When sorting by the App column, useSortedArray called
localeCompare on a boolean value, causing a TypeError crash. Changed the
fieldType to 'number' (JS boolean arithmetic works correctly for sorting)
and added defensive String() conversion in useSortedArray to prevent
similar type mismatch crashes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 18:54:02 +00:00
2 changed files with 5 additions and 7 deletions
@@ -55,7 +55,7 @@ const SETTINGS_OBJECT_RELATION_TABLE_METADATA: TableMetadata<FieldMetadataItem>
{
fieldLabel: msg`App`,
fieldName: 'isCustom',
fieldType: 'string',
fieldType: 'number',
align: 'left',
},
{
@@ -32,13 +32,11 @@ export const useSortedArray = <T>(
return [...arrayToSort].sort((a: T, b: T) => {
if (sortFieldType === 'string') {
const aValue = String(a[sortFieldName] ?? '');
const bValue = String(b[sortFieldName] ?? '');
return sortOrder === 'AscNullsLast' || sortOrder === 'AscNullsFirst'
? (a[sortFieldName] as string)?.localeCompare(
b[sortFieldName] as string,
)
: (b[sortFieldName] as string)?.localeCompare(
a[sortFieldName] as string,
);
? aValue.localeCompare(bValue)
: bValue.localeCompare(aValue);
} else if (sortFieldType === 'number') {
return sortOrder === 'AscNullsLast' || sortOrder === 'AscNullsFirst'
? (a[sortFieldName] as number) - (b[sortFieldName] as number)