* 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 <noreply@anthropic.com> * Browser: test that a new group in an empty folder shows and takes a dragged body (#10526) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user