From bb0b9a1d2fbcaf73741298c7a88161d93a2fdcf9 Mon Sep 17 00:00:00 2001 From: semmelrinde <124386289+semmelrinde@users.noreply.github.com> Date: Sun, 1 Nov 2026 09:44:17 +0000 Subject: [PATCH] Browser: a folder that holds only a new group shows it (#10526) (#10529) * Browser: a folder that holds only a new group shows it (#10526) New Group from the root's context menu made an empty group in the Bodies folder, but the Browser draws no folder without items, so in a design with no bodies yet nothing appeared. A folder that holds groups is now drawn with them, even before anything is in it. Co-Authored-By: Claude Opus 5.5 * Browser: test that a new group in an empty folder shows and takes a dragged body (#10526) Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Claude Opus 5.5 --- crates/ui-egui/src/browser_cache.rs | 12 ++++++++++-- crates/ui-egui/src/browser_card_tests.rs | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/browser_cache.rs b/crates/ui-egui/src/browser_cache.rs index 657343a18..b83b05817 100644 --- a/crates/ui-egui/src/browser_cache.rs +++ b/crates/ui-egui/src/browser_cache.rs @@ -205,7 +205,15 @@ impl Cache { "sketches" => &model.sketches, _ => &model.planes, }; - let Some(indices) = indices.get(&component) else { return Folder::default() }; + // A folder that holds only groups (a New Group made before anything is in it) is still + // drawn, or the group can't be seen or filled (#10526). + let grouped = doc.browser_groups.iter().any(|g| g.component == component && g.folder == folder); + let none = Vec::new(); + let indices = match indices.get(&component) { + Some(indices) => indices, + None if grouped => &none, + None => return Folder::default(), + }; let mut all = Vec::with_capacity(indices.len()); for i in indices { let entry = match folder { @@ -226,7 +234,7 @@ impl Cache { all.push(entry); } } - if all.is_empty() { + if all.is_empty() && !grouped { return Folder::default(); } let rows = arrange(&doc, component, folder, &prefix, all); diff --git a/crates/ui-egui/src/browser_card_tests.rs b/crates/ui-egui/src/browser_card_tests.rs index 8071361bf..01cdbf629 100644 --- a/crates/ui-egui/src/browser_card_tests.rs +++ b/crates/ui-egui/src/browser_card_tests.rs @@ -43,6 +43,27 @@ fn clicked_browser_folders_toggle_visibility_with_v() { } } +/// #10526: New Group from the root's context menu in a design with no bodies yet makes a group +/// the Browser shows, and a body made later can be dropped into it. +#[test] +fn a_new_group_in_a_folder_with_nothing_in_it_yet_shows() { + let mut h = Harness::new(); + h.app.home.open = false; + h.settle(); + assert!(handle_at("row:Bodies").is_none(), "no bodies, no Bodies folder"); + // What the root's New Group item runs. + group_action(&mut h.app, "ui.newGroup", &json!({"component": 0})); + h.settle(); + let group = h.app.session.doc.browser_groups.first().map(|g| (g.id, g.name.clone())).expect("New Group makes a group"); + assert!(handle_at(&format!("row:{} (0)", group.1)).is_some(), "the new group shows in the Browser"); + h.app.run("solid.box", json!({"length":10,"width":10,"height":10,"operation":"new_body","body_name":"One"})).unwrap(); + h.settle(); + h.step(&json!({"drag":[{"handle":"row:One"},{"handle":format!("row:{} (0)", group.1)}]})).unwrap(); + h.settle(); + let items = h.app.session.doc.browser_group(group.0).map(|g| g.items.len()).unwrap_or(0); + assert_eq!(items, 1, "the body went into the group"); +} + /// #10005: F2 on a group picked in the Browser opens its Rename box, as for other rows, and the /// typed name renames the group, at the top level and inside a component; a body selected /// alongside does not take the rename from the clicked group.