Description
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
- Attach listeners to both
beforeStarted
andreleased
on aDragRef
. - Press (
mousedown
) on the element. - Release (
mouseup
) without moving the pointer. - Observe:
beforeStarted
is emittedreleased
is not emitted
Environment
- Angular:
- CDK/Material: stackblitz
- Browser(s): chrome
- Operating System (e.g. Windows, macOS, Ubuntu): Windows
Activity
crisbeto commentedon May 28, 2025
The reason we don't emit the
release
event is that dragging hasn't actually started so there's nothing to release. As forbeforeStarted
being emitted, it's because we primarily introduced that event so we can sync the state between theCdkDrag
directive and the underlyingDragRef
which is why it fires more often.