LearnNewsExamplesServices
Frontmatter
id8614
titleFix moveNode off-by-one error for forward moves in same parent
stateClosed
labels
bugaicore
assigneestobiu
createdAtJan 13, 2026, 8:25 PM
updatedAtJan 13, 2026, 8:41 PM
githubUrlhttps://github.com/neomjs/neo/issues/8614
authortobiu
commentsCount1
parentIssue8601
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJan 13, 2026, 8:41 PM

Fix moveNode off-by-one error for forward moves in same parent

Closed v11.21.0 bugaicore
tobiu
tobiu commented on Jan 13, 2026, 8:25 PM

When moving a node forward within the same physical parent, DeltaUpdates.moveNode fails to account for the node's current position affecting childNodes indices. Test case: ['A', 'B', 'C']. Move 'A' to index 2 (after C). childNodes[2] is 'C'. insertBefore(A, C) results in ['B', 'A', 'C']. Expected: ['B', 'C', 'A'].

Fix: In Neo.main.DeltaUpdates.moveNode: If node.parentNode === parentNode (moving within same parent) AND currentIndex < index (moving forward), increment the lookup index for siblingRef (or check if index >= length - 1 for append).

tobiu added the bug label on Jan 13, 2026, 8:25 PM
tobiu added the ai label on Jan 13, 2026, 8:25 PM
tobiu added the core label on Jan 13, 2026, 8:25 PM
tobiu assigned to @tobiu on Jan 13, 2026, 8:26 PM
tobiu added parent issue #8601 on Jan 13, 2026, 8:26 PM
tobiu referenced in commit 5c4cae0 - "fix: Resolve moveNode off-by-one and silent remove in moveComponent (#8614)" on Jan 13, 2026, 8:41 PM
tobiu
tobiu Jan 13, 2026, 8:41 PM

Input from Gemini 3 Pro:

✦ Fixed the off-by-one error in DeltaUpdates.moveNode by adjusting index for same-parent forward moves. Also fixed App.moveComponent to correctly invoke remove(item, false, true) (Silent) to prevent double updates during moves, ensuring atomic moveNode deltas. Verified with FragmentLifecycle.spec.mjs.

tobiu closed this issue on Jan 13, 2026, 8:41 PM