From 1dce42e7441741076137d9519fb2269c34a73063 Mon Sep 17 00:00:00 2001 From: austin62jake Date: Thu, 29 Oct 2026 05:02:44 +0000 Subject: [PATCH] Preferences: a drop-down's Search box keeps what is typed in it (#8675) In Preferences, letters typed in a drop-down list's own Search box (the Font list, a 3D mouse's button assignments) went to the Preferences search instead, which then filtered the page, usually to "No matching preferences", and closed the list. The Preferences search takes typing only when no text field held the keyboard on the previous frame, and the drop-down's Search box never said it did. On the full Interface page the number fields' focus check covered for it; once a search hid them, as when the Font row is found by searching for "font", nothing did. The Search box in searchable_dropdown_with now reports that it has the keyboard, as the Preferences search box does. Co-authored-by: Claude --- crates/ui-egui/src/prefs.rs | 25 +++++++++++++++++++++++++ crates/ui-egui/src/ui_kit/fields.rs | 4 ++++ 2 files changed, 29 insertions(+) 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);