zed-industries/zed · error

DragMoveEvent is only valid when the stored active drag is o

Error message

DragMoveEvent is only valid when the stored active drag is of the same type.

What it means

DragMoveEvent::drag downcasts the App's active_drag value to the event's drag state type T and panics if it fails. The event type parameter must match the type passed to drag_start; a mismatch (listening for DragMoveEvent<A> while dragging B) makes the downcast impossible.

Source

Thrown at crates/gpui/src/elements/div.rs:79

    /// The specific style refinement that this group would apply
    /// to its children.
    pub style: Box<StyleRefinement>,
}

/// An event for when a drag is moving over this element, with the given state type.
pub struct DragMoveEvent<T> {
    /// The mouse move event that triggered this drag move event.
    pub event: MouseMoveEvent,

    /// The bounds of this element.
    pub bounds: Bounds<Pixels>,
    drag: PhantomData<T>,
    dragged_item: Arc<dyn Any>,
}

impl<T: 'static> DragMoveEvent<T> {
    /// Returns the drag state for this event.
    pub fn drag<'b>(&self, cx: &'b App) -> &'b T {
        cx.active_drag
            .as_ref()
            .and_then(|drag| drag.value.downcast_ref::<T>())
            .expect("DragMoveEvent is only valid when the stored active drag is of the same type.")
    }

    /// An item that is about to be dropped.
    pub fn dragged_item(&self) -> &dyn Any {
        self.dragged_item.as_ref()
    }
}

impl Interactivity {
    /// Create an `Interactivity`, capturing the caller location in debug mode.
    #[cfg(any(feature = "inspector", debug_assertions))]
    #[track_caller]
    pub fn new() -> Interactivity {
        Interactivity {

View on GitHub (pinned to 9d272b0363)

Solutions

  1. Make the DragMoveEvent type parameter match the type given to window.drag_start / the drag payload
  2. Before registering the handler, confirm which drag type is actually in flight
  3. If multiple drag types are possible, check cx.active_drag's type before using DragMoveEvent
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at crates/gpui/src/elements/div.rs:79 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20). Data as JSON: /api/errors/b2169ca8c2dbcf6c. Report an issue: GitHub.