From 9a0e6f8ae0c3aaa167694fde0868819e7ab4ff5b Mon Sep 17 00:00:00 2001 From: phanoob Date: Tue, 20 Oct 2026 12:36:37 +0000 Subject: [PATCH] A body dropped on a component's Bodies folder moves into that component (#3270) (#3347) * claim: #3270 Co-Authored-By: Claude Opus 5.5 * A body dropped on a component's Bodies folder moves into that component (#3270) The Bodies (and Sketches) folder row only took items of its own component, to take them out of groups. A body dragged there from another component was refused, though the folder looks like the place to drop it, so moving a body back to a parent seemed impossible. Items of the same folder from another component now move into the folder's component, as a drop on the component's own row does. Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Phanoob Co-authored-by: Claude Opus 5.5 --- crates/ui-egui/src/browser.rs | 12 ++++++++--- crates/ui-egui/src/occurrence_ui_tests.rs | 26 +++++++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/browser.rs b/crates/ui-egui/src/browser.rs index 42adc5cff..04c457275 100644 --- a/crates/ui-egui/src/browser.rs +++ b/crates/ui-egui/src/browser.rs @@ -1820,11 +1820,17 @@ fn folder_rows_at(app: &mut SolveApp, ui: &mut egui::Ui, comp: u64, path: Option if let Some(p) = r.secondary { acts.menu = Some((p, Target::Folder { component: comp, folder: fstatic.to_string(), scope: prefix.clone() })); } - // Dropping on the folder row takes items out of their groups, to the end. + // Dropping on the folder row takes items out of their groups, to the end. Bodies or sketches + // from another component's folder move into this component, as a drop on its row does + // (#3270: the Bodies folder looked like the place to drop a body, and took nothing). if let Some(resp) = &r.resp - && let Some(d) = drop_target(ui, resp, |d: &Drag| d.comp == comp && d.folder == fstatic, DropMark::Box) + && let Some(d) = drop_target(ui, resp, |d: &Drag| d.folder == fstatic && (d.comp == comp || d.folder != "construction"), DropMark::Box) { - acts.drop = Some(DropAction::Move { comp, folder: fstatic, keys: d.keys.clone(), group: None, before: None }); + acts.drop = Some(if d.comp == comp { + DropAction::Move { comp, folder: fstatic, keys: d.keys.clone(), group: None, before: None } + } else { + DropAction::Component { to: comp, folder: d.folder, keys: d.keys.clone() } + }); } if !open { return; diff --git a/crates/ui-egui/src/occurrence_ui_tests.rs b/crates/ui-egui/src/occurrence_ui_tests.rs index 0c1c698d5..18e3df738 100644 --- a/crates/ui-egui/src/occurrence_ui_tests.rs +++ b/crates/ui-egui/src/occurrence_ui_tests.rs @@ -230,3 +230,29 @@ fn occurrence_distance_editor_reads_inches_and_keeps_four_digits_in_model_space( crate::browser::revert_occurrence_dialog(&mut h.app, &movement); assert!(h.app.session.pending_moves.is_empty()); } + +/// #3270: a body dragged from a child component onto the parent's Bodies folder moves back into +/// the parent, as a drop on the parent's own row does. +#[test] +fn a_body_dropped_on_a_bodies_folder_moves_into_that_component() { + let mut h = Harness::new(); + h.app.home.open = false; + h.app.run("solid.box", json!({"length":10,"width":10,"height":10,"body_name":"Plate"})).unwrap(); + h.app.run("solid.box", json!({"corner":[20,0,0],"length":5,"width":5,"height":5,"body_name":"Lid"})).unwrap(); + let part = h.app.run("component.create", json!({"name":"Part"})).unwrap()["component"].as_u64().unwrap(); + h.app.run("solid.box", json!({"corner":[40,0,0],"length":5,"width":5,"height":5,"body_name":"Pin"})).unwrap(); + h.app.run("component.activate", json!({"component":0})).unwrap(); + h.frames(4); + let owner = |h: &Harness, name: &str| { + let state = h.app.session.model.state(); + h.app.session.doc.model_body_component(state.body(name).unwrap()) + }; + assert_eq!(owner(&h, "Pin"), part); + let at = |h: &mut Harness, handle: &str| h.at(&json!({"handle": handle})).unwrap(); + let (plate, lid, pin) = (at(&mut h, "row:Plate"), at(&mut h, "row:Lid"), at(&mut h, "row:Pin")); + // The root's Bodies folder row sits one row above its first body. + let folder = [plate[0], plate[1] - (lid[1] - plate[1])]; + h.step(&json!({"drag": [pin, folder], "steps": 12})).unwrap(); + h.frames(3); + assert_eq!(owner(&h, "Pin"), 0, "Pin moved back into the root component"); +}