2121import net .minecraft .client .gui .components .Button ;
2222import net .minecraft .client .gui .components .MultiLineLabel ;
2323import net .minecraft .client .gui .components .Tooltip ;
24+ import net .minecraft .client .gui .components .events .GuiEventListener ;
2425import net .minecraft .client .gui .components .tabs .Tab ;
2526import net .minecraft .client .gui .components .tabs .TabManager ;
2627import net .minecraft .client .gui .navigation .ScreenRectangle ;
@@ -214,7 +215,6 @@ public boolean mouseClicked(MouseButtonEvent mouseButtonEvent, boolean bl) {
214215 //?} else {
215216 /*@Override
216217 public boolean mouseClicked(double mouseX, double mouseY, int button) {
217- preferredTab = null;
218218 if (super.mouseClicked(mouseX, mouseY, button)) {
219219 this.setDragging(true);
220220 return true;
@@ -324,7 +324,7 @@ public static void renderMultilineTooltip(GuiGraphics graphics, Font font, Multi
324324 public void updateGlobalSearch (String search ) {
325325 Tab nextTabWithSearch = null ;
326326 if (preferredTab != null ) {
327- preferredTab .optionList .getList ().updateSearchQuery (search );
327+ preferredTab .optionList .getType ().updateSearchQuery (search );
328328 if (preferredTab .hasSearch ()) nextTabWithSearch = preferredTab ;
329329 }
330330 Tab currentTab = tabNavigationBar .getTabManager ().getCurrentTab ();
@@ -334,7 +334,7 @@ public void updateGlobalSearch(String search) {
334334 Tab tab = tabNavigationBar .getTabs ().get (i );
335335 if (tab == preferredTab ) continue ;
336336 if (tab instanceof CategoryTab categoryTab ) {
337- categoryTab .optionList .getList ().updateSearchQuery (search );
337+ categoryTab .optionList .getType ().updateSearchQuery (search );
338338 categoryTab .searchField .setValueDoNotUpdate (search );
339339 if (cursorPos != -1 ) categoryTab .searchField .setCursorPosition (cursorPos );
340340 if (nextTabWithSearch == null && categoryTab .hasSearch ()) {
@@ -352,6 +352,12 @@ public void updateGlobalSearch(String search) {
352352 tabNavigationBar .updateTabNames ();
353353 }
354354
355+ @ Override
356+ public void setFocused (@ Nullable GuiEventListener focused ) {
357+ super .setFocused (focused );
358+ if (focused != null && !(focused instanceof SearchFieldWidget )) preferredTab = null ;
359+ }
360+
355361 public static class CategoryTab implements TabExt {
356362 private static final ResourceLocation DARKER_BG = YACLPlatform .mcRl ("textures/gui/menu_list_background.png" );
357363
@@ -433,7 +439,7 @@ public CategoryTab(YACLScreen screen, ConfigCategory category, ScreenRectangle t
433439 }
434440
435441 public boolean hasSearch () {
436- return ! optionList .getList ().children ().isEmpty ( );
442+ return optionList .getType ().children ().stream (). anyMatch ( o -> o . searchQueryMatches );
437443 }
438444
439445 @ Override
0 commit comments