From 93d0298d254aad7100b2af995d157b41299d2b1a Mon Sep 17 00:00:00 2001 From: Christian Hammacher Date: Thu, 29 Oct 2026 11:28:19 +0000 Subject: [PATCH] Browser: Turn Up Axis on a placement row asks that placement whether it can move (#8786) (#8788) A placement row's menu starts from its component's menu, which takes Turn Up Axis's enabled state from the component's first placement. Move/Copy was already set again for the placement right-clicked; Turn Up Axis and its two turns now are too, so a free second placement can turn while the first is grounded, and a grounded one can't. Co-authored-by: Claude Opus 5.5 --- crates/ui-egui/src/context_menu.rs | 6 +++++- crates/ui-egui/src/occurrence_ui_tests.rs | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/context_menu.rs b/crates/ui-egui/src/context_menu.rs index 3dca67bb7..7c6fc5e81 100644 --- a/crates/ui-egui/src/context_menu.rs +++ b/crates/ui-egui/src/context_menu.rs @@ -833,6 +833,8 @@ fn occurrence_items(app: &SolveApp, path: &[u64]) -> Vec { entries.insert(0, Item::heading("Shared child: edits affect all copies of its parent")); } let bodies = app.session.occurrence_bodies(path, true).unwrap_or_default(); + // The component's menu asks its first placement; this row may be another one. + let movable = !placement.grounded && app.session.held_by_rigid_group(placement.occurrence).is_none(); for item in &mut entries { match item.id.as_str() { "ui.activate" => { @@ -846,11 +848,13 @@ fn occurrence_items(app: &SolveApp, path: &[u64]) -> Vec { } "ui.moveOccurrence" => { item.params = Some(json!({"occurrence": placement.occurrence, "path": path})); - item.enabled = !placement.grounded && app.session.held_by_rigid_group(placement.occurrence).is_none(); + item.enabled = movable; } "ui.properties" => item.params = Some(json!({"occurrence": placement.occurrence, "path": path})), "ui.turnUpAxis" => { + item.enabled = movable; for child in &mut item.children { + child.enabled = movable; if let Some(params) = child.params.as_mut() { params["occurrence"] = json!(placement.occurrence); } diff --git a/crates/ui-egui/src/occurrence_ui_tests.rs b/crates/ui-egui/src/occurrence_ui_tests.rs index 8ffbb2687..54f98b5b2 100644 --- a/crates/ui-egui/src/occurrence_ui_tests.rs +++ b/crates/ui-egui/src/occurrence_ui_tests.rs @@ -128,6 +128,24 @@ fn occurrence_second_row_selects_exact_path_and_menu_actions() { assert_eq!(h.app.session.active_occurrence_path, Some(vec![second])); } +#[test] +fn turn_up_axis_follows_the_placement_right_clicked() { + // Whichever placement comes first, a grounded one can't turn and a free one can. + let (mut h, _, first, second) = fixture(); + let turns = |h: &Harness, occurrence: u64| { + let items = context_menu::items(&h.app, &Target::Occurrence { path: vec![occurrence] }); + let turn = items.into_iter().find(|i| i.id == "ui.turnUpAxis").unwrap(); + let children: Vec<_> = turn.children.iter().map(|c| (c.enabled, c.params.as_ref().unwrap()["occurrence"].as_u64())).collect(); + (turn.enabled, children) + }; + for (grounded, free) in [(first, second), (second, first)] { + h.app.run("occurrence.ground", json!({"occurrence": grounded, "grounded": true})).unwrap(); + h.app.run("occurrence.ground", json!({"occurrence": free, "grounded": false})).unwrap(); + assert_eq!(turns(&h, free), (true, vec![(true, Some(free)); 2]), "free placement {free}"); + assert_eq!(turns(&h, grounded), (false, vec![(false, Some(grounded)); 2]), "grounded placement {grounded}"); + } +} + #[test] fn occurrence_eye_and_fold_are_independent_and_survive_rename() { let (mut h, component, first, second) = fixture();