{"record":{"id":"b2169ca8c2dbcf6c","repo":"zed-industries/zed","slug":"dragmoveevent-is-only-valid-when-the-stored-active","errorCode":null,"errorMessage":"DragMoveEvent is only valid when the stored active drag is of the same type.","messagePattern":"DragMoveEvent is only valid when the stored active drag is of the same type\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui/src/elements/div.rs","lineNumber":79,"sourceCode":"    /// The specific style refinement that this group would apply\n    /// to its children.\n    pub style: Box<StyleRefinement>,\n}\n\n/// An event for when a drag is moving over this element, with the given state type.\npub struct DragMoveEvent<T> {\n    /// The mouse move event that triggered this drag move event.\n    pub event: MouseMoveEvent,\n\n    /// The bounds of this element.\n    pub bounds: Bounds<Pixels>,\n    drag: PhantomData<T>,\n    dragged_item: Arc<dyn Any>,\n}\n\nimpl<T: 'static> DragMoveEvent<T> {\n    /// Returns the drag state for this event.\n    pub fn drag<'b>(&self, cx: &'b App) -> &'b T {\n        cx.active_drag\n            .as_ref()\n            .and_then(|drag| drag.value.downcast_ref::<T>())\n            .expect(\"DragMoveEvent is only valid when the stored active drag is of the same type.\")\n    }\n\n    /// An item that is about to be dropped.\n    pub fn dragged_item(&self) -> &dyn Any {\n        self.dragged_item.as_ref()\n    }\n}\n\nimpl Interactivity {\n    /// Create an `Interactivity`, capturing the caller location in debug mode.\n    #[cfg(any(feature = \"inspector\", debug_assertions))]\n    #[track_caller]\n    pub fn new() -> Interactivity {\n        Interactivity {","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/gpui/src/elements/div.rs#L61-L97","documentation":"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.","triggerScenarios":"Thrown at crates/gpui/src/elements/div.rs:79 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Make the DragMoveEvent type parameter match the type given to window.drag_start / the drag payload","Before registering the handler, confirm which drag type is actually in flight","If multiple drag types are possible, check cx.active_drag's type before using DragMoveEvent"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}