From 257b4d138c7dbb13752f07ff309d521d603c37dd Mon Sep 17 00:00:00 2001 From: Patrick Huang Date: Fri, 17 Jun 2022 19:46:55 +0200 Subject: Fix T93446: search box active result does not reset when typing Whenever the user edits the query in a search box, the active (highlighted) result resets to the first. Previously, it would remain at the last highlighted result, jumping around as the results update. This is better than the previous behavior. If a user highlights a choice either on purpose or by accidental mouse movement and continues to type, it is likely that they are not looking for the currently highlighted choice, so setting it to the top search result is more useful. Differential Revision: https://developer.blender.org/D15211 --- source/blender/editors/interface/interface_region_search.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source/blender/editors/interface/interface_region_search.cc') diff --git a/source/blender/editors/interface/interface_region_search.cc b/source/blender/editors/interface/interface_region_search.cc index 64de31dfe6a..81c0c29d09a 100644 --- a/source/blender/editors/interface/interface_region_search.cc +++ b/source/blender/editors/interface/interface_region_search.cc @@ -451,15 +451,16 @@ void ui_searchbox_update(bContext *C, ARegion *region, uiBut *but, const bool re /* reset vars */ data->items.totitem = 0; data->items.more = 0; - if (reset == false) { + if (!reset) { data->items.offset_i = data->items.offset; } else { data->items.offset_i = data->items.offset = 0; data->active = -1; - /* handle active */ - if (search_but->items_update_fn && search_but->item_active) { + /* On init, find and center active item. */ + const bool is_first_search = !search_but->but.changed; + if (is_first_search && search_but->items_update_fn && search_but->item_active) { data->items.active = search_but->item_active; ui_searchbox_update_fn(C, search_but, but->editstr, &data->items); data->items.active = nullptr; -- cgit v1.2.3