Skip to content

bug(DragRef): 'released' event not firing if element wasn't moved #31194

Closed
@DywiTom

Description

@DywiTom

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

According to the DragRef documentation, the released event is described as:

"Emits when the user has released a drag item, before any animations have started."

However, this event is only emitted if the dragged element was actually moved.
If I just press and release the mouse (i.e., mousedown followed by mouseup) without moving the element, the released event does not fire.

Interestingly, the beforeStarted event does fire in this case — even though dragging never really began. This creates an inconsistent event lifecycle.

Reproduction

StackBlitz link:
https://stackblitz.com/edit/dv56brss?file=src%2Fexample%2Fcdk-drag-drop-overview-example.ts

Steps to reproduce:
Click element, see console.log.

Expected Behavior

Both beforeStarted and released should behave consistently.
If beforeStarted fires, released should follow on mouse release — even when the element hasn't been moved.

Actual Behavior

  1. Attach listeners to both beforeStarted and released on a DragRef.
  2. Press (mousedown) on the element.
  3. Release (mouseup) without moving the pointer.
  4. Observe:
    • beforeStarted is emitted
    • released is not emitted

Environment

  • Angular:
  • CDK/Material: stackblitz
  • Browser(s): chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows

Activity

crisbeto

crisbeto commented on May 28, 2025

@crisbeto
Member

The reason we don't emit the release event is that dragging hasn't actually started so there's nothing to release. As for beforeStarted being emitted, it's because we primarily introduced that event so we can sync the state between the CdkDrag directive and the underlying DragRef which is why it fires more often.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageThis issue needs to be triaged by the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      bug(DragRef): 'released' event not firing if element wasn't moved · Issue #31194 · angular/components