From 102bd021136ae2d2d2abd85a9fcdbb4f80440ff4 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Wed, 25 Nov 2026 15:52:59 +0700 Subject: [PATCH] Docking test: the report names the panel that has the keys after a click in its search field. A press on a dock tab now leaves the keys where they were (craft-libs TabStrip::keeps_focus), so the tab click alone no longer focuses the panel; the search lookup is a harness helper both tests use --- crates/ui-egui/src/panel_docking/tests.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/panel_docking/tests.rs b/crates/ui-egui/src/panel_docking/tests.rs index 2544e8756a..9d91f0d6be 100644 --- a/crates/ui-egui/src/panel_docking/tests.rs +++ b/crates/ui-egui/src/panel_docking/tests.rs @@ -62,6 +62,15 @@ impl Harness { .map(|b| Rect::from_min_max(pos2(b.x0 as f32, b.y0 as f32), pos2(b.x1 as f32, b.y1 as f32))) } + /// The centre of the text field named `label` in the last frame. + fn text_field(&self, label: &str) -> Option { + self.nodes + .iter() + .filter(|(_, n)| n.role() == egui::accesskit::Role::TextInput && n.label() == Some(label)) + .find_map(|(_, n)| n.bounds()) + .map(|b| pos2(((b.x0 + b.x1) / 2.0) as f32, ((b.y0 + b.y1) / 2.0) as f32)) + } + fn tab(&self, panel: &str) -> Option { self.named(panel, egui::accesskit::Role::Tab) } @@ -679,6 +688,9 @@ fn ui_docking_reports_the_layout_and_the_dock_state() { h.frame(vec![]); let tab = h.tab("layers").unwrap(); h.click(tab.center()); + // A press on a tab leaves the keys where they were (the dock's TabStrip::keeps_focus); a click in the panel's + // search field gives the panel the keys. + h.click(h.text_field("Search layers").expect("the Layers panel's search field")); let report = inspect(&h.app, &h.ctx); assert_eq!(report["layout"], serde_json::to_value(h.layout()).unwrap()); assert_eq!(report["focused"], json!("layers")); @@ -814,13 +826,7 @@ fn other_function_keys_and_keyboard_guards_keep_their_routes() { // The Layers panel's search field, clicked once the dialog has gone: it has the keys until a click on the canvas // takes them. h.frames(2); - let field = h - .nodes - .iter() - .filter(|(_, n)| n.role() == egui::accesskit::Role::TextInput && n.label() == Some("Search layers")) - .find_map(|(_, n)| n.bounds()) - .map(|b| pos2(((b.x0 + b.x1) / 2.0) as f32, ((b.y0 + b.y1) / 2.0) as f32)) - .expect("the Layers panel's search field"); + let field = h.text_field("Search layers").expect("the Layers panel's search field"); h.click(field); h.f7(); assert!(showing(&h.app.ui, "layers"), "F7 does nothing while a text field has focus");