Frontmatter
| id | 8054 |
| title | [Draggable] Investigate sorting corruption after multiple live drag operations |
| state | Closed |
| labels | bugai |
| assignees | tobiu |
| createdAt | Dec 7, 2025, 8:11 PM |
| updatedAt | Dec 11, 2025, 3:18 AM |
| githubUrl | https://github.com/neomjs/neo/issues/8054 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Dec 11, 2025, 3:18 AM |
[Draggable] Investigate sorting corruption after multiple live drag operations
tobiu assigned to @tobiu on Dec 7, 2025, 8:11 PM

tobiu
Dec 11, 2025, 3:17 AM
Input from Gemini 2.5 pro:
✦ I have identified and fixed the root cause of the sorting corruption.
Root Cause: The
Neo.draggable.dashboard.SortZoneclass contained amoveTooverride that was performing redundant and incorrect index re-mapping.
- The base
SortZoneclass already calculatesfromIndexandtoIndexrelative to theowner.itemsarray.- The
DashboardSortZoneoverride incorrectly treated these indices as relative tosortableItemsand attempted to map them back toowner.itemsa second time.- This logic critically failed when the
dragPlaceholderwas involved (which is not inowner.items), resulting in indices resolving to-1.Neo.util.Array.move(-1, ...)then moves the last item in the array, causing the scrambled sorting behavior.The Fix: I have removed the faulty
moveTomethod fromsrc/draggable/dashboard/SortZone.mjs. The class now correctly inherits the base implementation fromSortZone, which:
- Correctly identifies the
fromIndexusing thedragComponentreference (bypassing the placeholder issue).- Correctly identifies the
toIndexusing the target sortable item.- Calls
owner.moveTo()with the correct, 0-based indices for the full items array.Verification: I verified this fix with a simulation script covering:
- Standard sorting operations.
- Complex "mixed content" scenarios (e.g., Toolbars with non-sortable separators) to ensure no regressions were introduced. The base logic correctly handles these cases by mapping sortable indices to their true positions in the
owner.itemsarray.
tobiu closed this issue on Dec 11, 2025, 3:18 AM
tobiu cross-referenced by #8086 on Dec 11, 2025, 3:29 AM
While the "Manual DOM Delta" strategy for live dragging works correctly for the first drag operation, subsequent drag operations result in incorrect item ordering in the UI, despite
moveToseemingly receiving correct indices.Observed Behavior:
[A(0), B(1), C(2)]moveTo(2, 1). Result:[A, C, B]. (Correct).moveTo(0, 1). Result:[A, B, C]. (Incorrect - seems to revert/scramble).Potential Causes:
SortZonelogic relies onitemRects. IfgetDomRectreturns rects reflecting a stale or unexpected DOM order, the sorting logic degrades.moveTologic relies onowner.itemsorder. We need to verify ifowner.itemsis actually persisting the order change from Op 1 correctly.Task: Investigate the state of
owner.items, DOM structure, and VDOM structure across multiple drag operations to identify why the visual order desynchronizes.