LearnNewsExamplesConnect
Frontmatter
assigneesneo-gemini-julia
createdAtNov 4, 2026, 2:02 PM
updatedAtNov 4, 2026, 9:06 PM
githubUrlhttps://github.com/neomjs/neo/issues/20275
authorneo-gemini-julia
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[ ] 20284 A filter on a dotted path never matches raw items or undeclared paths
closedAtNov 4, 2026, 9:06 PM

Resolve dotted property paths in collection.Sorter, collection.Base, and data.TreeStore sorting

neo-gemini-julia
neo-gemini-julia commented on Nov 4, 2026, 2:02 PM

Problem

Neo.grid.Row (src/grid/Row.mjs) reads cell values via record.get(column.dataField), and Neo.data.Record#get(field) (src/data/RecordFactory.mjs:239-249) resolves both declared Model fields (this[field]) and undeclared dotted paths (if (field.includes('.')) return Neo.ns(field, false, this[dataSymbol])). Similarly, Neo.data.Store#getKey resolves dotted keyProperty paths on raw objects via Neo.ns.

However, sorting a collection, Store, or TreeStore by a dotted property path (such as a grid column with dataField: 'stats.running.throughput' pointing into an Object field or nested plain object) currently fails as a no-op:

  1. Neo.collection.Sorter#defaultSortBy (src/collection/Sorter.mjs:123-135) and Neo.collection.Base#doSort (src/collection/Base.mjs:776-798) read item[property] directly. When property is a dotted path that is not a flat own property or declared Model getter on item, item[property] evaluates to undefined for every item, leaving the collection order unchanged.
  2. Neo.data.TreeStore#sortArray (src/data/TreeStore.mjs:1011-1075) duplicates Neo.collection.Base#doSort's array-sorting logic to sort localized #childrenMap arrays in place, and has drifted behind collection.Base#doSort: it reads item[sortProperties[i]] directly, still uses {index, original: item} (vulnerable to the property: 'index' collision fixed in #20270), and uses raw > / < comparisons rather than Sorter.compareValues (fixed in #4044).
  3. Neo.data.Store#doSort (src/data/Store.mjs:603-605) and Neo.data.TreeStore#doSort (src/data/TreeStore.mjs:410-412) in Turbo Mode (autoInitRecords: false) with model.hasComplexFields === true execute if (!Object.hasOwn(item, property)) { item[property] = me.resolveField(item, property) }. When property is an undeclared dotted path (!me.model.getField(property)), resolveField returns undefined (while resolveField already caches item[fieldName] = value for declared fields at Store.mjs:1693), so the caller stamps an own property item['a.b'] = undefined onto the raw item.

Design authority: tier-2 — local to src/collection/Sorter.mjs, src/collection/Base.mjs, src/data/Store.mjs, and src/data/TreeStore.mjs; extends property resolution to dotted paths while preserving $O(1)$ direct property/Symbol access and consolidating sortArray(arr) on Neo.collection.Base.

Solution

  1. Add static getValue(item, property) on Neo.collection.Sorter (src/collection/Sorter.mjs):
    • First reads let value = item?.[property] so flat properties, Symbol keys (such as Symbol.for('initialIndex') in Store#sort()), and declared Model getters remain $O(1)$.
    • When value === undefined && typeof property === 'string' && property.includes('.'), resolves item.get(property) if typeof item.get === 'function' (Neo.data.Record instances) and falls back to Neo.ns(property, false, item) (plain objects in Collection / Turbo Mode Stores or calculated root getters on Records).
  2. Wire Sorter.getValue into Sorter#defaultSortBy and move sortArray(arr) to Neo.collection.Base (src/collection/Base.mjs), where doSort(items=this._items, silent=false) delegates in-place array sorting to this.sortArray(items) (retaining this._items = items so filter()'s this.doSort(this.items, true) commits the sorted shallow clone from items_'s clone: 'shallow' getter) and Neo.data.TreeStore inherits sortArray(arr) directly (deleting the 65-line duplicated TreeStore#sortArray in src/data/TreeStore.mjs).
  3. In Neo.data.Store#resolveField (src/data/Store.mjs), when !field and typeof fieldName === 'string' && fieldName.includes('.'), resolve the root segment (fieldName.split('.')[0]) if it is a declared Model field not yet on item and return Neo.ns(fieldName, false, item) without stamping a flat item[fieldName] cache key; update Store#doSort, Store#filter, TreeStore#doSort, and TreeStore#filter to call me.resolveField(item, property) without overwriting item[property] = undefined when !me.model.getField(property).

Contract Ledger

Symbol Visibility Signature / Input Return / Side Effects
Neo.collection.Sorter.getValue public static (item: Object|Neo.data.Record|null|undefined, property: String|Symbol) Returns undefined when !item. Otherwise reads item[property] directly ($O(1)$ for flat keys, Symbols, and declared Record getters); if undefined and typeof property === 'string' && property.includes('.'), calls item.get(property) when typeof item.get === 'function', then falls back to Neo.ns(property, false, item). Mutates nothing.
Neo.collection.Base#sortArray protected (arr: Object[]) Returns undefined (sorts and mutates arr in place using the collection's active sorters, Sorter.getValue, Sorter.compareValues, and a non-colliding Symbol('sortPosition') key; early-exits unchanged if < 2 items or 0 sorters). Inherited by Neo.data.TreeStore for #childrenMap sibling arrays.
Neo.data.Store#resolveField public (item: Object, fieldName: String) For a declared Model field, computes and caches item[fieldName] = value and returns value. For an undeclared dotted fieldName (!field && fieldName.includes('.')), soft-hydrates rootField = fieldName.split('.')[0] on item if rootField is a declared Model field and !Object.hasOwn(item, rootField), then returns Neo.ns(fieldName, false, item) without stamping item[fieldName]. Returns undefined for unknown flat names.

Acceptance Criteria

  • AC-1 (Sorter.getValue & Collection sorting): Neo.collection.Sorter.getValue(item, property) resolves dotted string paths on both Neo.data.Record instances and plain objects while keeping flat properties and Symbol keys (Symbol.for('initialIndex')) intact, and Neo.collection.Base sorts items by dotted property paths with useTransformValue: true, useTransformValue: false, and mixed sortBy + defaultSortBy sorters.
  • AC-2 (Store & TreeStore sorting in Record and Turbo modes): Neo.data.Store and Neo.data.TreeStore sort by dotted property paths (including paths inside Object fields and calculated complex root fields) in both autoInitRecords: true (Record instances) and autoInitRecords: false (Turbo Mode raw objects) without stamping item['a.b'] = undefined on raw objects, and re-sorting reflects live mutations to nested properties.
  • AC-3 (TreeStore#sortArray deduplication): Neo.data.TreeStore inherits sortArray(arr) from Neo.collection.Base (removing the duplicate implementation in src/data/TreeStore.mjs), gaining Sorter.getValue, Sorter.compareValues, and sortPosition Symbol safety (property: 'index').
  • AC-4 (Unit tests): Playwright unit tests in test/playwright/unit/collection/SortDottedProperty.spec.mjs cover dotted property sorting across Collection, Store (Record + Turbo Mode + live nested mutation + store.sort() reset), and TreeStore (Record + Turbo Mode), and existing collection/ and data/ unit suites pass.
tobiu referenced in commit 20006c1 - "fix(collection): resolve dotted property paths in Sorter, Collection, and TreeStore (#20275) (#20276) on Nov 4, 2026, 9:06 PM
tobiu closed this issue on Nov 4, 2026, 9:06 PM