mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-24 06:28:34 +01:00
fix: Table sorting for ID and date columns (#802)
The usage of `parseFloat` was breaking the sorting of ID and date
columns in the table.
This is because `parseFloat("000-123")` returns `0` instead of `123` or
`NaN`, and `parseFloat("2025-01-02T03:04:05.678Z")` returns `2025`.
Replacing `parseFloat` with `Number` fixes the issue, as now the values
received for Asset ID and date columns will correctly return `NaN`, and
end up being sorted as strings.
This commit is contained in:
committed by
GitHub
parent
c53cefe6cb
commit
8493ec0c90
@@ -256,8 +256,8 @@
|
|||||||
function extractSortable(item: ItemSummary, property: keyof ItemSummary): string | number | boolean {
|
function extractSortable(item: ItemSummary, property: keyof ItemSummary): string | number | boolean {
|
||||||
const value = item[property];
|
const value = item[property];
|
||||||
if (typeof value === "string") {
|
if (typeof value === "string") {
|
||||||
// Try parse float
|
// Try to parse number
|
||||||
const parsed = parseFloat(value);
|
const parsed = Number(value);
|
||||||
if (!isNaN(parsed)) {
|
if (!isNaN(parsed)) {
|
||||||
return parsed;
|
return parsed;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user