forge
Explore
Log in

Don't you dare go Hollow

A file dropped on the library panel imports — the room hears the drop, not the centre

Browse files at this commit

9bb9951719095c4a3294b00646c1653157c762a1Ahmet Kaan GümüşParent: 7fbbd0f
  • fix
    • a file dropped on the library panel imports — the room hears the drop, not the centre
Show full message
🐛 fix(app): a file dropped on the library panel imports — the room hears the drop, not the centre

The external-file drop handler (gpui `ExternalPaths`, Wayland
`text/uri-list`) sat on `stance-centre`, the flex column between the spine
and the dock. The dock — the Sources/library panel — is that column's
sibling, so its hitbox was never under any drop listener and a file dragged
onto the library landed on nothing at all.

Moved to the room root (`stance-room`), the one surface under every region:
a drop anywhere in the darkroom now goes through `Player::import`, the same
door the Import action, argv and Paste path use. The dock and the centre
each lift to the raised fill while a file is over them — the same affordance
every other drop target in the room answers a drag with, no plate, no copy.
crates/app/src/tests/layout.rsmodified+45 -0
@@ -2649,3 +2649,48 @@ fn hitmap_names_every_darkroom_pointer_entry_surface() {
2649 }2649 }
2650 }2650 }
2651 }2651 }
2652+
2653+/// An external file drag (gpui `ExternalPaths`, Wayland `text/uri-list`) has
2654+/// to be heard over the DOCK -- the Sources/library panel -- and not only
2655+/// over the centre column: the dock and the spine are the centre's flex
2656+/// siblings, so the handler `stance-centre` used to carry covered none of
2657+/// the library panel, which is exactly the shipped "drag and drop file
2658+/// import is not working on library panel" defect. The listener therefore
2659+/// belongs to the room root (`stance-room`), above every region, and it must
2660+/// route the dropped paths through `import` -- the same door the Import
2661+/// action uses.
2662+///
2663+/// A scan, not a click: this crate has no gpui `VisualTestContext` harness
2664+/// (nothing in `tests/` opens a window), and a drop cannot be simulated
2665+/// without one -- the compositor half (`wl_data_device`) is out of reach of
2666+/// the test process either way.
2667+#[test]
2668+fn an_external_file_drop_is_heard_by_the_whole_room_and_imports() {
2669+ let stance = src_text("ui/stance.rs");
2670+ let root_at = stance
2671+ .find(".id(\"stance-room\")")
2672+ .expect("no stance root div");
2673+ let centre_at = stance
2674+ .find(".id(\"stance-centre\")")
2675+ .expect("no stance centre column");
2676+ let drop_at = stance
2677+ .find(".on_drop(cx.listener(|this, paths: &gpui::ExternalPaths")
2678+ .expect("no external-file drop handler in the stance");
2679+ assert!(
2680+ drop_at > root_at && drop_at < centre_at,
2681+ "the external drop handler is not on the room root -- \
2682+ a drop over the dock's library panel is heard by nothing"
2683+ );
2684+ let body = &stance[drop_at..(drop_at + 700).min(stance.len())];
2685+ assert!(
2686+ body.contains("this.import(path, cx)"),
2687+ "a dropped file does not go through the import door: {body}"
2688+ );
2689+ // ...and the library panel says so while the file is over it.
2690+ let dock_at = stance.find(".id(\"stance-dock\")").expect("no dock div");
2691+ let dock = &stance[dock_at..(dock_at + 700).min(stance.len())];
2692+ assert!(
2693+ dock.contains(".drag_over::<gpui::ExternalPaths>"),
2694+ "the dock answers an external file drag with nothing: {dock}"
2695+ );
2696+}
crates/app/src/ui/stance.rsmodified+28 -20
@@ -829,6 +829,11 @@ fn dock(
829 ) -> impl IntoElement {829 ) -> impl IntoElement {
830 div()830 div()
831 .id("stance-dock")831 .id("stance-dock")
832+ // The library's own answer to a file dragged in from outside: the
833+ // same raised fill every other drop target in the darkroom lifts to
834+ // (DESIGN §8's affordance, no plate and no copy). The drop itself is
835+ // heard by the room root (`render`), which covers this panel too.
836+ .drag_over::<gpui::ExternalPaths>(|d, _, _, _| d.bg(rgb(DARK_RAISED())))
832 .flex_none()837 .flex_none()
833 .w(px(dock_w))838 .w(px(dock_w))
834 .h_full()839 .h_full()
@@ -1047,6 +1052,25 @@ pub(crate) fn render(
1047 // ruler-scrub is (render.rs): the pointer outruns the 6px divider1052 // ruler-scrub is (render.rs): the pointer outruns the 6px divider
1048 // hitbox on the first move, so only the whole-window root keeps1053 // hitbox on the first move, so only the whole-window root keeps
1049 // hearing it once a `Split::Dock`/`Split::Bench` drag has started.1054 // hearing it once a `Split::Dock`/`Split::Bench` drag has started.
1055+ // A file dropped from outside the window (gpui's `ExternalPaths`,
1056+ // Wayland's `text/uri-list`) lands on the room itself, not on the
1057+ // centre column: the dock's Sources panel and the spine are the
1058+ // centre's flex siblings, so a handler mounted there heard no drop
1059+ // over the library at all -- the shipped "drag and drop import does
1060+ // not work on the library panel" defect. Here it is the one surface
1061+ // under every region, so a drop anywhere in the darkroom is heard.
1062+ // No prior press starts this -- the drop itself arrives as a
1063+ // `MouseUp` (gpui `window.rs`).
1064+ .on_drop(cx.listener(|this, paths: &gpui::ExternalPaths, _, cx| {
1065+ // `Player::import` is the one door a project or media path
1066+ // already goes through (argv, the Import button, Paste path) --
1067+ // it forks on `.edith` vs everything else itself (`arrival`) and
1068+ // already refuses during an export, so a drop names nothing this
1069+ // loop has to.
1070+ for path in paths.paths() {
1071+ this.import(path, cx);
1072+ }
1073+ }))
1050 .on_mouse_move(cx.listener(Player::drag_move))1074 .on_mouse_move(cx.listener(Player::drag_move))
1051 .on_mouse_up(MouseButton::Left, cx.listener(Player::drag_release))1075 .on_mouse_up(MouseButton::Left, cx.listener(Player::drag_release))
1052 .size_full()1076 .size_full()
@@ -1058,31 +1082,15 @@ pub(crate) fn render(
1058 .child(1082 .child(
1059 div()1083 div()
1060 .id("stance-centre")1084 .id("stance-centre")
1085+ // Same drag affordance the dock lifts to, on the other half
1086+ // of the room: the drop is heard by the root above, this
1087+ // only says where the file will land.
1088+ .drag_over::<gpui::ExternalPaths>(|d, _, _, _| d.bg(rgb(DARK_RAISED())))
1061 .relative()1089 .relative()
1062 .flex_1()1090 .flex_1()
1063 .min_w(px(0.))1091 .min_w(px(0.))
1064 .flex()1092 .flex()
1065 .flex_col()1093 .flex_col()
1066- // A file dropped from outside the window (gpui's
1067- // `ExternalPaths`, Wayland's `text/uri-list`) lands here: the
1068- // one room-wide surface under everything else drawn below,
1069- // so a drop anywhere in the darkroom is heard. No prior
1070- // press starts this -- the drop itself arrives as a
1071- // `MouseUp` (`window.rs`) -- and the tint is the same
1072- // raised fill every other drop target in the darkroom
1073- // answers a drag with, DESIGN §8's affordance without a
1074- // word of copy on it.
1075- .drag_over::<gpui::ExternalPaths>(|d, _, _, _| d.bg(rgb(DARK_RAISED())))
1076- .on_drop(cx.listener(|this, paths: &gpui::ExternalPaths, _, cx| {
1077- // `Player::import` is the one door a project or media
1078- // path already goes through (argv, the Import button,
1079- // Paste path) -- it forks on `.edith` vs everything else
1080- // itself (`arrival`) and already refuses during an
1081- // export, so a drop names nothing this loop has to.
1082- for path in paths.paths() {
1083- this.import(path, cx);
1084- }
1085- }))
1086 .child(screen(player, position, window, cx))1094 .child(screen(player, position, window, cx))
1087 .child(time_band(player, position, cx))1095 .child(time_band(player, position, cx))
1088 .child(divider(Split::Bench, cx))1096 .child(divider(Split::Bench, cx))