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 <noreply@anthropic.com>
This commit is contained in:
austin62jake
2026-10-29 05:02:44 +00:00
committed by GitHub
parent aad3d56ec2
commit 1dce42e744
2 changed files with 29 additions and 0 deletions
+25
View File
@@ -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
+4
View File
@@ -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);