LearnNewsExamplesServices
Frontmatter
id8626
titleContainer.insert() should be a no-op for same-index moves
stateClosed
labels
bugaicore
assigneestobiu
createdAtJan 14, 2026, 1:15 AM
updatedAtJan 14, 2026, 1:27 AM
githubUrlhttps://github.com/neomjs/neo/issues/8626
authortobiu
commentsCount1
parentIssue8601
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJan 14, 2026, 1:27 AM

Container.insert() should be a no-op for same-index moves

Closed v11.21.0 bugaicore
tobiu
tobiu commented on Jan 14, 2026, 1:15 AM

Currently, Neo.container.Base.insert(index, item) does not check if the item is already at the specified index within the same container. It proceeds to remove and re-insert the item, which triggers unnecessary VDOM updates and potentially destabilizes complex components (like Fragments) or focus state.

Goal: Modify Neo.container.Base.insert() to detect this condition and return early (no-op) if the item is already at the target index.

Logic:

if (item.parent === this && this.items.indexOf(item) === index) {
    return item;
}

Impact:

  • Prevents redundant DOM updates.
  • Improves stability for repeated actions (like clicking "Move" buttons multiple times).
  • Reduces VDOM diffing overhead.
tobiu added the bug label on Jan 14, 2026, 1:15 AM
tobiu added the ai label on Jan 14, 2026, 1:15 AM
tobiu added the core label on Jan 14, 2026, 1:15 AM
tobiu added parent issue #8601 on Jan 14, 2026, 1:16 AM
tobiu assigned to @tobiu on Jan 14, 2026, 1:25 AM
tobiu
tobiu Jan 14, 2026, 1:27 AM

Input from Gemini 3 Pro:

✦ I have implemented the no-op check in Neo.container.Base.insert() to prevent unnecessary VDOM updates when inserting an item into its current position. I also refactored the method to reduce redundant calls to Neo.typeOf and item.parent.

The changes were committed in 6ad5eaf3b (mistakenly referenced as #8627 in the commit message).

Changes committed and pushed.

tobiu closed this issue on Jan 14, 2026, 1:27 AM
tobiu cross-referenced by #8616 on Jan 14, 2026, 1:51 AM
tobiu cross-referenced by #8625 on Jan 14, 2026, 1:59 AM