LearnNewsExamplesServices
Frontmatter
id8053
title[Draggable] Implement Manual DOM Delta Strategy for Live Component Dragging
stateClosed
labels
enhancementaiarchitecture
assigneestobiu
createdAtDec 7, 2025, 8:01 PM
updatedAtDec 7, 2025, 8:09 PM
githubUrlhttps://github.com/neomjs/neo/issues/8053
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtDec 7, 2025, 8:09 PM

[Draggable] Implement Manual DOM Delta Strategy for Live Component Dragging

Closed v11.17.0 enhancementaiarchitecture
tobiu
tobiu commented on Dec 7, 2025, 8:01 PM

Implement a robust "Manual DOM Delta" strategy to enable dragging of live components without losing state.

Problem: Dragging components typically involves moving them in the VDOM tree, which triggers a destroy/create cycle for the underlying DOM node. This breaks stateful elements like OffscreenCanvas or Iframe that rely on a persistent DOM instance.

Solution:

  1. DragZone: Update createDragProxy to use Neo.applyDeltas for a manual move operation.

    • Instead of modifying the owner's items config (VDOM), we manually move the component's DOM node into the DragProxy.
    • We manually insert a placeholder vnode (fetched via Neo.vdom.Helper) into the owner's DOM to maintain the layout gap.
    • Configured DragProxyContainer with parentComponent: me.owner to maintain logical linkage for event bubbling.
    • Ensured neo-draggable class is on the proxy config to support event delegation.
  2. SortZone: Update onDragEnd to perform a manual restoration.

    • Before calling moveTo (which syncs the VDOM), we manually move the component's DOM node back to its correct visual position in the owner and remove the placeholder node.
    • This ensures the VDOM update sees a DOM structure that matches its expectation, preventing a destructive reconciliation.
    • Corrected fromIndex calculation to use me.dragComponent (live reference) instead of proxy items.
    • Updated updateItem to handle the placeholder (mapped index -1) and redirect updates appropriately.

Changed Files:

  • src/draggable/DragZone.mjs
  • src/draggable/container/SortZone.mjs
tobiu added the enhancement label on Dec 7, 2025, 8:01 PM
tobiu added the ai label on Dec 7, 2025, 8:01 PM
tobiu added the architecture label on Dec 7, 2025, 8:01 PM
tobiu assigned to @tobiu on Dec 7, 2025, 8:02 PM
tobiu referenced in commit 356532b - "[Draggable] Implement Manual DOM Delta Strategy for Live Component Dragging #8053" on Dec 7, 2025, 8:05 PM
tobiu closed this issue on Dec 7, 2025, 8:09 PM