-
-
Notifications
You must be signed in to change notification settings - Fork 202
Bug / Enhancement: Fix unstable sorting & enforce nulls at bottom #9311
Copy link
Copy link
Closed
Labels
aibugSomething isn't workingSomething isn't workingcoreCore framework functionalityCore framework functionalityenhancementNew feature or requestNew feature or request
Description
Sorting columns with mapped data and missing values (like company in DevIndex) resulted in unstable, varying sort orders that seemingly "improved" the more times a sort was triggered.
This occurred due to two overlapping issues:
- Soft Hydration Inconsistency:
Neo.data.Store#resolveFieldwas returningundefinedfor missing mapped keys on raw objects, while fully hydrated records correctly received theirdefaultValue(e.g.,null). - JavaScript Sorting Transitivity:
Neo.collection.BaseandNeo.collection.Sorterrelied on standard<and>operators. In JS,nullandundefinedevaluate as "equal" to strings (both<and>returnfalse), breaking sorting transitivity and causing random scrambling of the array.
This ticket fixes the bug by introducing an enhancement to the framework's sorting paradigm: null and undefined values are now always pushed to the bottom of the collection, regardless of whether the sort direction is ASC or DESC.
Changes:
src/data/Store.mjs: UpdatedresolveField()to applydefaultValueif the raw value isundefined.src/collection/Base.mjs: Added explicit== nullisolation logic todoSort()to always pushnull/undefinedvalues to the bottom.src/collection/Sorter.mjs: Added explicit== nullisolation logic todefaultSortBy()to always pushnull/undefinedvalues to the bottom.test/playwright/unit/collection/SortNull.spec.mjs: Added a new unit test to explicitly verify this behavior.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
aibugSomething isn't workingSomething isn't workingcoreCore framework functionalityCore framework functionalityenhancementNew feature or requestNew feature or request