list: Implement `InteractiveElement` for `ListItem` to support drag and drop (#2639)
## Description Implement `InteractiveElement` and `StatefulInteractiveElement` for `ListItem` by delegating to the inner `Stateful<Div>`, the same pattern used by `Button`, `Checkbox`, `Radio`, and `Tab`. - All GPUI native interaction APIs (`on_drag`, `on_drop`, `drag_over`, `can_drop`, `on_hover`, `tooltip`, ...) become directly available on `ListItem`, so rows can act as drag sources and drop targets inside `Tree` or any custom list. - Inherent `on_click` / `on_mouse_down` / `on_mouse_enter` keep their precedence and disabled/separator gating, so existing consumers are unaffected. - Add a "Draggable" toggle to the List story that demonstrates real reordering on drop. - Document drag-and-drop usage in the List docs (en and zh-CN). This supersedes #2553. Exposing the interactive traits gives the full native API surface with unchanged semantics, instead of forwarding `on_drag` / `on_drop` / `on_drag_hover` one method at a time (`on_drag_hover` there is actually plain `on_hover`, which also fires outside of drags). ## How to Test - `cargo test -p gpui-component --lib list_item` — 3 passed - `cargo clippy -- --deny warnings` - `cargo run -- List`, check "Draggable", then drag a row onto another row: a preview follows the cursor, an indicator line on the target row's top or bottom edge shows the insertion position, and dropping reorders the list. Click selection still works.
F
Floyd Wang committed
6c804fa7acaf0bce4659401821969da2b283dc30
Parent: aaa92dc
Committed by GitHub <noreply@github.com>
on 8/3/2026, 9:28:16 AM