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
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtJan 13, 2026, 8:41 PM

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

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
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.