LearnNewsExamplesServices
Frontmatter
id19300
titleEscape does not cancel a drag once it has crossed into another window
stateClosed
labels
bugai
assigneesneo-opus-ada
createdAtSep 26, 2026, 10:41 PM
updatedAtSep 26, 2026, 11:39 PM
githubUrlhttps://github.com/neomjs/neo/issues/19300
authorneo-opus-ada
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtSep 26, 2026, 11:39 PM

Escape does not cancel a drag once it has crossed into another window

neo-opus-ada
neo-opus-ada commented on Sep 26, 2026, 10:41 PM

Context

Operator's hand run, 2026-09-26 (with #19278): dragging a tab inside the main window and pressing Esc recovers the previous state. It does not when the popup proxy (a converted vessel) is active, or when the tab proxy stands inside a different window.

The Problem

The cancel itself already works across windows. DragCoordinator#onDragCancel leaves the remote target, resets the vessel conversion (sourceSortZone.resetVesselConversion) and clears the native-window drop candidates.

What fails is delivery. Escape is heard only by the main-thread DragDrop addon of the window where the gesture started:

  • onKeyDown fires only when event.key === 'Escape' && me.dragZoneId.
  • dragZoneId is set in that window's own onDragStart.

During a converted or cross-window drag, the keyboard focus is in another window, the vessel or the target popup. Its DragDrop has no dragZoneId, so Escape is dropped.

The Architectural Reality

  • src/main/addon/DragDrop.mjs: onKeyDown (a global capture listener, addGlobalEventListeners) holds the Escape guard. It sets dragCancelled, cancels a resize, and sends one drag:cancel carrying the zone id. Its remote API (remote.app) has no cancel entry.
  • src/manager/DomEvent.mjs: routes a drag:cancel to Neo.get(data.dragZoneId).onDragCancel, and ignores one without a zone. fire() receives the worker message; its windowId rides on the message (worker.Manager#sendMessage), not in data.
  • src/manager/DragCoordinator.mjs: activeSourceZone is set only when onDragMove enters an admitted target, and cleared on void (handleVoid). While a conversion is pending, the coordinator cannot name the gesture's owner (@neo-gpt's source read, confirmed).
  • The one authority valid in every phase is the window whose DragDrop holds dragZoneId.

The Fix

  1. DragDrop gains a remote cancelDrag(). It runs the Escape guard's cancel branch for the gesture this window owns, and it is a no-op without one or when the gesture is already cancelled.
  2. Escape in a window without a gesture of its own sends one drag:cancel marked crossWindow and carrying no zone id. The key's default stays with that window's UI.
  3. DomEvent hands such a message, with the message's windowId, to DragCoordinator#cancelCrossWindowGesture. It asks every other app window to cancelDrag. It reads no gesture state, so a pending conversion cannot hide the owner.

From there the existing path runs unchanged: the owner's drag:cancel, TabSortZone#onDragCancel (which retires a converted or still-transitioning vessel), then DragCoordinator#onDragCancel.

Contract Ledger

Target Surface Source of Authority Proposed Behavior Fallback / Edge Case Docs Evidence
Neo.main.addon.DragDrop#cancelDrag (new, remote.app) this ticket Cancels the gesture this window owns: dragCancelled set, a resize cancelled, one drag:cancel with dragZoneId No gesture, or already cancelled: sends nothing JSDoc AC-3
drag:cancel marked crossWindow (new payload) this ticket Sent by DragDrop#onKeyDown on Escape when this window owns no gesture; no preventDefault Sent on every such Escape, drag or not: one message, plus one no-op cancelDrag per other window of a multi-window app; none in a single-window app JSDoc AC-1, AC-2
DragCoordinator#cancelCrossWindowGesture (new) this ticket Asks cancelDrag of every Neo.apps window except the one that heard Escape A rejected remote call (e.g. a closing window) is swallowed JSDoc AC-2

Acceptance Criteria

  • AC-1 (unit, red first): DragDrop#onKeyDown without a local gesture sends one drag:cancel marked crossWindow, without preventDefault. The local-gesture path is unchanged.
  • AC-2 (unit, red first): a crossWindow cancel in the shape worker.Manager#sendMessage posts (the windowId on the message) asks cancelDrag of every other app window, and not of the window that heard Escape.
  • AC-3 (unit): DragDrop#cancelDrag cancels the owned gesture once, with one drag:cancel carrying the zone id. A second call, or a call without a gesture, sends nothing.
  • AC-4 (runtime): pressing Escape on the target window's page during a converted drag restores the pre-drag layout: the tab back at its source and no vessel left. It is measured headless, with #19288's screen flag, in the large-over-small journey.
  • AC-5 (unit, pin): a cancel while the conversion is still pending (transitioning, no target admitted) retires the vessel as a converted cancel does. The behaviour already exists; the arm pins it, and dropping transitioning from TabSortZone#onDragCancel fails it.

Post-Merge Validation

  • The operator's hand run: Esc during a vessel or cross-window tab proxy drag recovers the previous state.

Out of Scope

Related

#19248, #19278 / #19289, #19297, #19298.

Sweeps:

  • The latest open issues, read live at 20:35Z: no equivalent.
  • No A2A claim on Escape or cancel.
  • My own assignments: none on this surface.

Origin Session ID: 40558e40-aee4-4461-946d-a389266a3256 Retrieval Hint: "Escape cancel cross-window drag vessel DragDrop onKeyDown dragZoneId crossWindow cancelDrag"

tobiu referenced in commit cb91585 - "fix(dock): Escape cancels a drag that crossed into another window (#19300) (#19301) on Sep 26, 2026, 11:39 PM
tobiu closed this issue on Sep 26, 2026, 11:39 PM