diff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rs index eab7e3593..4613b9069 100644 --- a/crates/ui-egui/src/prefs.rs +++ b/crates/ui-egui/src/prefs.rs @@ -5051,6 +5051,31 @@ mod tests { assert!(crate::scenario::rect_of("prefs:ok").is_some()); } + /// Letters typed in the font list's own Search box narrow the list. Preferences' search takes + /// typing only when no text field has the keyboard, so it must not take these. + #[test] + fn typing_in_the_font_lists_search_narrows_the_list_not_the_page() { + use serde_json::json; + let mut h = crate::scenario::Harness::new(); + h.call("ui.prefs", json!({"open":"Interface"})); + // Found by searching, as the setting is far down the page. + h.step(&json!({"text": "font"})).expect("search"); + h.frames(3); + let combo = crate::scenario::handle_at("prefs:ui_font").expect("the search finds the font row"); + h.call("ui.click", json!({"x":combo.x,"y":combo.y})); + h.frames(2); + let search = format!("dialog:{} search", crate::i18n::tr("prefs.font")); + let field = crate::scenario::handle_at(&search).expect("the font list is open"); + h.call("ui.click", json!({"x":field.x,"y":field.y})); + h.frames(2); + h.step(&json!({"text": "Comic"})).expect("type"); + h.frames(2); + assert_eq!(h.app.prefs_window.filter, "font", "the Preferences search took the letters"); + assert_eq!(h.app.prefs_window.font_filter, "Comic", "the font list's search keeps them"); + assert!(crate::scenario::handle_at(&search).is_some(), "the font list stays open"); + h.call("ui.prefs", json!({"button":"cancel"})); + } + #[test] fn number_fields_take_a_decimal_point_or_a_decimal_comma() { // #1347 diff --git a/crates/ui-egui/src/ui_kit/fields.rs b/crates/ui-egui/src/ui_kit/fields.rs index 67bd00e1f..90a501cdf 100644 --- a/crates/ui-egui/src/ui_kit/fields.rs +++ b/crates/ui-egui/src/ui_kit/fields.rs @@ -207,6 +207,10 @@ fn searchable_dropdown_with( .hint_text(crate::i18n::tr_label("Search")) .desired_width(f32::INFINITY), ); + // Preferences types into its own search only while no field has the keyboard. + if search.has_focus() { + crate::prefs_search::note_key_sink(ui.ctx()); + } scenario::publish_handle(&format!("dialog:{row} search"), search.rect.center()); if let Some(custom) = custom { let response = ui.selectable_label(false, custom);