LearnNewsExamplesConnect
Frontmatter
assigneesneo-opus-grace
createdAtNov 7, 2026, 1:19 AM
updatedAtNov 7, 2026, 1:17 PM
githubUrlhttps://github.com/neomjs/neo/issues/20510
authorneo-gemini-maryam
commentsCount1
parentIssue20379
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtNov 7, 2026, 1:17 PM

Grid header drag-and-drop scrambles grouped leaves on cross-group/region drops and traps ungrouped columns behind groups

Closed v13.4.0/archive-v13-4-0-chunk-4 bugaigriddrag-and-drop
neo-gemini-maryam
neo-gemini-maryam commented on Nov 7, 2026, 1:19 AM

Context

During the Engine 13.4 release-gate verification matrix on #20379 (Grid columns can sit under a shared group header, merged via #20397 + #20502, evaluated on dev at ccb30d8d6e), real-pointer Playwright + Neural Link testing on examples/grid/headerGroups surfaced three defects in Neo.draggable.grid.header.toolbar.SortZone and Neo.draggable.container.SortZone covering Matrix Rows 2 and 4.

The Problem

Measured in Chromium on examples/grid/headerGroups (dev at ccb30d8d6e):

  1. Row 2A & Row 4B — Dragging a non-boundary grouped leaf into another group or region scrambles its own group order instead of refusing the drop:
    • test/playwright/e2e/grid/HeaderGroups.spec.mjs:139-141, 177 only tested leaves that were already sitting at the boundary edge of their group (Mar at index 2 dragged right into Q2, Apr at index 3 dragged left into Q1, and Jan at index 0 dragged left onto Region).
    • When dragging Jan (index 0 of Q1: ['Jan', 'Feb', 'Mar']) rightward and releasing over May (in Q2), SortZone swaps Jan past Feb and Mar (0 → 1 → 2), refuses only the 2 → 3 boundary crossing, and commits currentIndex = 2 on drop — mutating Q1 to ['Feb', 'Mar', 'Jan'] (ROW_2A_JAN_TO_MAY_ORDER: ["Feb","Mar","Jan","Apr","May","Jun"]) even though the user dropped on Q2.
    • Likewise, when dragging Mar (index 2 of Q1) leftward and releasing over Region (locked: 'start'), Mar stays in center (SortZone.mjs:419-420), but Q1 is mutated to ['Mar', 'Jan', 'Feb'] (ROW_4A_MAR_TO_REGION: {"start":["Region"],"center":["Mar","Jan","Feb","Apr","May","Jun"]}).
  2. Row 2B — An ungrouped column is permanently trapped behind a group in the same region:
    • When dragging ungrouped Id (index 12, after Q4) leftward to place it before Q4 (Oct) in center, container/SortZone#onDragMove only steps currentIndex by ±1 (12 → 11, which is Dec in Q4). Because switchItems(12, 11) checks getHeaderGroupId(12) !== getHeaderGroupId(11) (null !== Q4), it refuses the swap and resets currentIndex = 12 (ROW_2B_ID_PAST_Q4_ORDER remains [...,"Oct","Nov","Dec","Id"]). An ungrouped column can never be reordered past a group within the same region.
  3. Row 4C — Overdrag loop at internal group boundaries (src/draggable/container/SortZone.mjs:799-861):
    • When a grouped leaf at an internal group boundary (Apr at index 3 dragged left past localBoundary.left, or Mar at index 2 dragged right past localBoundary.right when the centre toolbar overflows) enters isOverDraggingStart / isOverDraggingEnd, onDragMove decrements/increments me.currentIndex, awaits me.scrollToIndex(), and calls me.switchItems(index, me.currentIndex), which resets me.currentIndex = index. Because me.currentIndex !== 0 && me.currentIndex !== maxItems (line 853), me.isOverDragging stays true and re-schedules onDragMove every 30ms.

The Architectural Reality

  • Neo.draggable.grid.header.toolbar.SortZone#switchItems(index1, index2) (src/draggable/grid/header/toolbar/SortZone.mjs:561-567) guards individual adjacent swaps (if (me.getHeaderGroupId(index1) !== me.getHeaderGroupId(index2)) { me.currentIndex = index1; return }), while Neo.draggable.container.SortZone#onDragMove (src/draggable/container/SortZone.mjs:827-839) advances currentIndex one neighbour at a time (index ± 1).
  • Because swaps inside the dragged leaf's own group succeed while the pointer moves toward another group or another region, me.indexMap and me.itemRects are already mutated by the time the pointer leaves the group. Simply clamping currentIndex at the group boundary leaves the leaf at the boundary edge instead of either restoring me.startIndex on an invalid cross-group/cross-region drop or keeping the leaf constrained cleanly.
  • For an ungrouped column (getHeaderGroupId(index1) === null) crossing an adjacent group (getHeaderGroupId(index2) !== null), the atomic unit in the leaf toolbar is the entire contiguous run of index2's headerGroup.id — an ungrouped column cannot land inside the group, but once the pointer crosses past the group's span, it must shift the contiguous group run as a block rather than halting at the first leaf of the group.

Design authority: #20379 (Grid columns can sit under a shared group header) + 13.4 release-gate verification matrix (Rows 2 & 4).

The Fix

  1. Preserve within-group order when a grouped leaf is released outside its group or over another region (Rows 2A & 4B):
    • If a grouped leaf is released over a different group or a different region (lastDragClientX outside its group / over another region), or if within-group clamping is used, ensure that releasing a non-boundary leaf (e.g. Jan dropped on May, or Mar dropped on Region) does not silently commit an unintended reorder of its own group (restore startIndex when released outside the group's valid drop zone, or only reorder while the pointer is within the group's horizontal bounds).
  2. Allow ungrouped columns to reorder past a group in the same region (Row 2B):
    • When an ungrouped leaf (getHeaderGroupId(index1) === null) is dragged across a group (getHeaderGroupId(index2) !== null), allow it to step across the entire contiguous group run ([groupStart..groupEnd]) as a unit once the pointer crosses the group's threshold, so Id dragged before Q4 lands at [..., 'Id', 'Oct', 'Nov', 'Dec'] without splitting Q4.
  3. Prevent isOverDragging infinite retry when switchItems refuses a boundary step (Row 4C):
    • In src/draggable/container/SortZone.mjs:799-861, if switchItems refused the step (me.currentIndex === index), do not keep me.isOverDragging = true spinning when no further swap in that direction is possible.

Contract Ledger

Target surface Source of authority Proposed behavior Fallback / edge case Docs Evidence
SortZone#switchItems / onDragEnd (src/draggable/grid/header/toolbar/SortZone.mjs) #20379 Fix step 4 + Matrix Rows 2A, 2B, 4B Grouped leaf reorders inside its group when dropped inside its group; dropping a non-boundary leaf (Jan, Mar) on another group or region leaves its group's initial order intact; ungrouped leaf (Id) can cross past an entire group (Q4) without splitting it Single-leaf group or ungrouped columns without groups behave as today JSDoc on SortZone methods test/playwright/e2e/grid/HeaderGroups.spec.mjs (Jan → May, Mar → Region, Id before Q4)
container/SortZone#onDragMove overdrag guard (src/draggable/container/SortZone.mjs:799-861) Matrix Row 4C isOverDragging terminates cleanly when a group boundary refuses switchItems Normal container SortZone overdrag at 0..maxItems unchanged Inline comment + JSDoc E2E cross-region / boundary drag in HeaderGroups.spec.mjs

Decision Record impact: none.

Acceptance Criteria

  • AC-1 (Row 2A & Row 4B — Non-boundary grouped leaf drop): Dragging Jan (first leaf of Q1) onto May (Q2) and dragging Mar (last leaf of Q1) onto Region (locked: 'start') both leave Q1 in its original order ['Jan', 'Feb', 'Mar'] (e2e).
  • AC-2 (Row 2B — Ungrouped column across a group): Dragging ungrouped Id leftward past Q4 (Oct, Nov, Dec) places Id immediately before Oct while keeping Q4 contiguous (['Id', 'Oct', 'Nov', 'Dec']) and Q4's group cell aligned with Oct..Dec (e2e).
  • AC-3 (Row 4C — Overdrag boundary termination): Overdragging a grouped boundary leaf (Apr or Mar) past the toolbar edge does not stick isOverDragging in a loop when switchItems refuses the swap.

Out of Scope

  • Group-cell drag (.neo-grid-header-group-cell in GroupRow, Matrix Row 3): #20379 explicitly scoped out dragging a whole group header cell; with clean leaf reorder + ungrouped-across-group stepping (AC-1..AC-3), group-cell drag is deferred to a post-13.4 feature leaf unless the operator rules otherwise.
  • Emptying a locked region (startEmptied / endEmptied in Wrapper.mjs) and runtime column.locked mutation splitting a group (tracked in #20511 under #20379).
  • Column resize on flex columns and mid-drag GroupRow#project() during resize (tracked in #20512 / PR #20514 under #20379).

Avoided Traps

  • Only testing boundary leaves (Mar → May, Apr → Jan, Jan → Region): a leaf already at the edge of its group has 0 in-group swaps before hitting the boundary, hiding the currentIndex mutation on every non-boundary leaf.
  • Allowing an ungrouped column to stop mid-group: when an ungrouped column crosses a group, it must jump the full group span so the group's leaves never split into two runs.

Related

Parent #20379 · Shipped PRs #20397, #20502 (#20501) · #20511 · #20512 (#20514) · #12903 (within-region column drag) · #9486 / #9872 (multi-body grid architecture).

Sweeps

  • Live latest-open + closed sweep: Checked latest 20 open issues (#20506 down to #17889) and latest 20 closed issues (#20501, #9872, etc.) in neomjs/neo at 2026-11-07T00:16Z; read #20379 and #20501 in full. No duplicate open issue exists.
  • A2A in-flight claim sweep: Checked latest 30 all-state messages (2026-11-07T00:14Z); filed per @neo-fable-clio (MESSAGE:a01b83f0, MESSAGE:7a168cfd) and assigned to @neo-opus-grace per her explicit handoff (MESSAGE:4340bffa: "Any red row comes to me to fix today").
  • Memory Core & KB sweep: Queried query_raw_memories and ask_knowledge_base for grid headerGroups 20379 SortZone Wrapper Resizable onColumnLockChange.
  • Own-assignment sweep: Checked @neo-gemini-maryam open assignments in neomjs/neo (#19575 only; no overlap).
  • Structure-map gate: N/A (existing Engine files src/draggable/grid/header/toolbar/SortZone.mjs, src/draggable/container/SortZone.mjs).

Origin Session ID: 444579f0-7e38-4519-831e-f7e5aabe8f44 Retrieval Hint: "grid headerGroups SortZone switchItems Jan to May Mar to Region Id past Q4 20379"

🧭 Maryam (@neo-gemini-maryam · Gemini 4 Argon · Antigravity)

tobiu referenced in commit 9347902 - "feat(grid): a header drag keeps every header group in one piece (#20510) (#20520) on Nov 7, 2026, 1:17 PM
tobiu closed this issue on Nov 7, 2026, 1:17 PM