Preferences: typing in a number field edits it instead of searching (#8662) (#8663)

* claim: #8662

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Preferences: typing in a number field edits it instead of searching (#8662)

Type-to-search takes printable keys unless the focused field notes the key
sink. number_field (Autosave every, the Largest file to open limits) never
did, so its digits went into the search.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
N3MI-DG
2026-10-29 05:32:25 +00:00
committed by GitHub
parent 54f74a613e
commit 0818ad0ed4
2 changed files with 19 additions and 0 deletions
+16
View File
@@ -746,6 +746,22 @@ mod tests {
assert_eq!(h.app.prefs_window.section, crate::prefs::PAGE_GRAPHICS, "Escape returns to the page from before the search");
}
/// Typing in a number field (the largest STEP file) edits that field instead of starting
/// a search.
#[test]
fn preferences_number_fields_keep_typed_text() {
let mut h = crate::scenario::Harness::new();
h.app.home.open = false;
crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_GENERAL);
h.frames(2);
let field = crate::scenario::rect_of("prefs:max_step_file_mb").expect("STEP limit field");
h.step(&serde_json::json!({"click": [field.center().x, field.center().y]})).expect("click the field");
h.frames(2);
h.step(&serde_json::json!({"text": "7"})).expect("type");
h.frames(2);
assert!(h.app.prefs_window.filter.is_empty(), "typed `{}` into the search", h.app.prefs_window.filter);
}
/// The selected match is scrolled to when the arrows move it, not on every frame, so the
/// wheel can scroll the results away from it.
#[test]
+3
View File
@@ -852,6 +852,9 @@ pub(crate) fn number_field<T: egui::emath::Numeric>(
suffix: &str,
) -> Response {
let response = ui.add(egui::DragValue::new(value).range(range).speed(speed).suffix(suffix).custom_parser(crate::prefs::parse_number));
if response.has_focus() {
crate::prefs_search::note_key_sink(ui.ctx());
}
Tokens::get().input_bevel(ui, &response);
response.widget_info(|| {
let mut info = egui::WidgetInfo::drag_value(ui.is_enabled(), value.to_f64());