Skip to content

Commit

Permalink
fixed case insensitive sorting for Ktable
Browse files Browse the repository at this point in the history
  • Loading branch information
BabyElias committed Dec 7, 2024
1 parent 20f9350 commit a1f07b0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/KTable/useSorting/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function useSorting(headers, rows, defaultSort, disableBuiltinSor
const sortedRows = computed(() => {
if (disableBuiltinSorting.value) return rows.value;

// No sort key or value has been explicity set till now
// No sort key or value has been explicitly set till now
if (sortKey.value === null || sortOrder.value === null) {
if (defaultSort.value.index === -1) return rows.value;

Expand All @@ -40,7 +40,13 @@ export default function useSorting(headers, rows, defaultSort, disableBuiltinSor
);
}

return _.orderBy(rows.value, [row => row[sortKey.value]], [sortOrder.value]);
return _.orderBy(rows.value, [row => {
const value = row[sortKey.value];
if (typeof value === 'string') {
return value.toString().toLocaleLowerCase();
}
return value;
}], [sortOrder.value]);
});

/**
Expand Down Expand Up @@ -85,4 +91,4 @@ export default function useSorting(headers, rows, defaultSort, disableBuiltinSor
handleSort,
getAriaSort,
};
}
}

0 comments on commit a1f07b0

Please sign in to comment.