* claim: #7947 * Browser: reveal a placed body's row when it is picked or found (#7947) The off-screen skip in `entry_row` keeps the reveal target's row alive so it still has a rect to scroll to, but it matched `app.tree.reveal` (a world body name) against `Entry::key` (the placement-local name). For a placed body those never match, so the row returned early and the `scroll_to_rect` below it, which does use `row_key`, was never reached. `app.tree.reveal` is then cleared at the end of the frame, so there was no second chance. Match the skip on `row_key` minus its `b:` prefix, as the `scroll_to_rect` already does. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -2427,7 +2427,8 @@ fn entry_row(
|
||||
let pattern_key = e.patterns.as_deref();
|
||||
let patterns_open = pattern_key.is_some_and(|key| is_open(app, key, true));
|
||||
let rect = row_rect(ui);
|
||||
if !ui.is_rect_visible(rect) && !patterns_open && !(folder == "bodies" && app.tree.reveal.as_deref() == Some(e.key.as_str())) {
|
||||
let revealed = folder == "bodies" && app.tree.reveal.as_ref().is_some_and(|b| e.row_key.strip_prefix("b:") == Some(b.as_str()));
|
||||
if !ui.is_rect_visible(rect) && !patterns_open && !revealed {
|
||||
ui.allocate_space(rect.size());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -402,6 +402,38 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn browser_find_reveals_a_placed_body_whose_row_is_off_screen() {
|
||||
let mut h = Harness::new();
|
||||
let component = h.app.run("component.create", json!({"name":"Part"})).unwrap();
|
||||
h.app.run("solid.box", json!({"length":10,"width":10,"height":10,"body_name":"Plate"})).unwrap();
|
||||
h.app.run("component.activate", json!({"component":0})).unwrap();
|
||||
let first = component["occurrence"].as_u64().unwrap();
|
||||
// Enough placements that the last one's row sits below the Browser's visible height.
|
||||
let mut last = first;
|
||||
for i in 1..=80 {
|
||||
last = h.app.run("occurrence.copy", json!({"occurrence":first,"translate":[20.0 * f64::from(i),0,0]})).unwrap()["occurrence"]
|
||||
.as_u64()
|
||||
.unwrap();
|
||||
}
|
||||
h.app.run("browser.collapse_all", json!({})).unwrap();
|
||||
h.frames(2);
|
||||
let world_body = h.app.session.occurrence_bodies(&[last], false).unwrap()[0].clone();
|
||||
// A later placement's body has its own world name; the row's label stays the local one.
|
||||
assert_ne!(world_body, "Plate");
|
||||
let plate_rows = || drawn_rows().into_iter().filter(|(label, ..)| label == "Plate").count();
|
||||
assert_eq!(plate_rows(), 0, "the body starts off screen and collapsed");
|
||||
find_in_browser(&mut h.app, face(&world_body));
|
||||
// The row is off screen, so the reveal only gives it a rect to scroll to; the scroll then
|
||||
// animates over several frames until the row is on screen and drawn.
|
||||
let arrived = (0..240).any(|_| {
|
||||
h.frames(1);
|
||||
plate_rows() == 1
|
||||
});
|
||||
assert!(arrived, "the off-screen placed body row was never scrolled into view");
|
||||
assert_eq!(h.app.session.selection, [Sel::Body { name: world_body }]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn browser_feature_imported_source_ids_never_reveal_an_unrelated_native_feature() {
|
||||
struct Source(std::path::PathBuf);
|
||||
|
||||
Reference in New Issue
Block a user