mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
fix(DataTable): handle null/undefined values when sorting (#846)
This commit is contained in:
parent
16c377945c
commit
d3eb146fb5
1 changed files with 4 additions and 0 deletions
|
@ -194,6 +194,10 @@
|
|||
if (typeof itemA === "number" && typeof itemB === "number")
|
||||
return itemA - itemB;
|
||||
|
||||
if ([itemA, itemB].every((item) => !item && item !== 0)) return 0;
|
||||
if (!itemA && itemA !== 0) return ascending ? 1 : -1;
|
||||
if (!itemB && itemB !== 0) return ascending ? -1 : 1;
|
||||
|
||||
return itemA
|
||||
.toString()
|
||||
.localeCompare(itemB.toString(), "en", { numeric: true });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue