Skip to content

Public API to cancel an in-progress interaction (linking, drag, resize, rotate) #747

Description

@Mateusz-Jagodzinski

Problem

There's no public, supported way to abort an in-progress interactive gesture. actionState is read-only; the mutating ActionStateManager.clear*() methods are only reachable from inside a middleware (triggered by an action), not from app code reacting to, say, a key press. And even when reached, clearLinking()/clearResize()/etc. only null the state slice — the gesture's document listeners are removed only in each directive's own cleanup() on pointerup, so the gesture isn't truly torn down.

Motivating use case

"Press Esc to abort" — the temporary edge (or drag/resize/rotate preview) should disappear on the keypress, not on the eventual pointer release. This also matters when drop-on-empty-canvas has app-defined meaning (e.g. creating a dangling edge), so there's otherwise no way to back out.

Proposal

A public NgDiagramService.cancelActiveInteraction() (and/or per-tool cancelLinking(), cancelResize(), …) that fully aborts the active gesture: nulls the action state, runs the owning directive's listener cleanup, and emits the corresponding *Ended event with a cancel reason (e.g. add 'cancelled' to EdgeDrawCancelReason). Optionally a built-in Esc shortcut action bound to it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions