[Bf-blender-cvs] [257b4d138c7] master: Fix T93446: search box active result does not reset when typing

Patrick Huang noreply at git.blender.org
Fri Jun 17 19:53:10 CEST 2022


Commit: 257b4d138c7dbb13752f07ff309d521d603c37dd
Author: Patrick Huang
Date:   Fri Jun 17 19:46:55 2022 +0200
Branches: master
https://developer.blender.org/rB257b4d138c7dbb13752f07ff309d521d603c37dd

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

===================================================================

M	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;



More information about the Bf-blender-cvs mailing list