fix(ui): keep profile-name typing out of Preferences search (#9505) (#9568)

Report focused keyboard ownership from the shared text editor, matching the other Preferences fields. Regress real Name-field typing, focus retention, unchanged search text, and saving the resulting profile.
This commit is contained in:
PapaEcho
2026-11-02 00:12:36 +00:00
committed by GitHub
parent 6f73bd95c4
commit f43198988d
2 changed files with 28 additions and 0 deletions
@@ -330,6 +330,31 @@ fn starting_a_profile_command_opens_preferences_instead_of_failing() {
assert!(h.app.prefs_window.open);
}
#[test]
fn typing_a_profile_name_keeps_focus_out_of_preferences_search() {
let mut h = Harness::new();
h.app.home.open = false;
h.call("ui.prefs", json!({"open": "General"}));
h.frames(3);
h.step(&json!({"text": "profiles"})).expect("find Settings profiles");
h.frames(3);
h.step(&json!({"click": {"handle": "dialog:Name"}})).expect("focus the profile name");
h.frames(2);
let name_focus = h.ctx.memory(|memory| memory.focused()).expect("the name field has focus");
for text in ["Lap", "top"] {
h.step(&json!({"text": text})).expect("type a profile name");
h.frames(2);
assert_eq!(h.app.prefs_window.filter, "profiles", "profile-name text went to Preferences search");
assert_eq!(h.ctx.memory(|memory| memory.focused()), Some(name_focus), "the name field keeps focus");
}
assert!(h.widget("Laptop").is_some(), "the name field contains the typed name");
h.step(&json!({"widget": "Save"})).expect("save the profile");
h.frames(2);
assert_eq!(h.app.settings_profiles.active.as_deref(), Some("Laptop"));
assert_eq!(h.app.settings_profiles.names(), ["Laptop"]);
assert_eq!(h.app.prefs_window.filter, "profiles");
}
#[test]
fn choosing_a_profile_in_preferences_applies_it() {
let mut h = Harness::new();
+3
View File
@@ -667,6 +667,9 @@ fn editor_reserving(ui: &mut Ui, value: &mut String, hint: &str, completion: boo
ui.ctx().data_mut(|data| data.insert_temp(egui::Id::new("sc_focused_editor"), response.id));
}
super::text_menu::menu(ui, &mut response, value, super::text_menu::Field::LINE);
if response.has_focus() {
crate::prefs_search::note_key_sink(ui.ctx());
}
if completion && ui.is_enabled() {
ui.ctx().data_mut(|data| {
let id = egui::Id::new("sc_value_fields");