diff options
author | Patrick Huang <phuang1024> | 2022-06-17 20:46:55 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2022-06-17 20:51:13 +0300 |
commit | 257b4d138c7dbb13752f07ff309d521d603c37dd (patch) | |
tree | fa9d55669a130b44a596b4e2e265cb257c784378 | |
parent | 33bad77043d3ec4b91bc302af69da8c7ba9dd204 (diff) |
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
-rw-r--r-- | source/blender/editors/interface/interface_region_search.cc | 7 |
1 files changed, 4 insertions, 3 deletions
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; |