shedaniel / cloth-config

Client-Sided API for Minecraft 1.14
Other
194 stars 70 forks source link

Subcategory entries are still clickable after being filtered out by the search bar #245

Open Estecka opened 9 months ago

Estecka commented 9 months ago

Hi,

I have an issue that occurs when using the search field together with sub-categories: Entries that are being filtered out are still clickable, and will often overlap with other visible entries, causing the wrong entry to be modified when clicking one.

For example, here's how I interpret the details: On the left is the config screen as it appears after searching for "1". On the right is the would-be layout of the same screen if the search bar was empty 2024-02-23_01 34 02

Entries in red on the right have been filtered out, but are still overlaped onto the left screen. Trying to click the red entries on the left will result in the corresponding entry on the right to be toggled instead. The red area of the background can also be used to toggle hidden entries.

Entries in green are those that are still visible on the left. They've been moved around, so they leave out holes through which entries on the left can be toggled.

Here is the config screen I'm using in this screenshot:

public class TestScreen
{
    static public Screen createScreen(Screen parent){
        final ConfigBuilder builder = ConfigBuilder.create();
        final ConfigEntryBuilder entries = builder.entryBuilder();

        final ConfigCategory main = builder.getOrCreateCategory(Text.literal("Main"));
        final SubCategoryBuilder sub  = entries.startSubCategory(Text.literal("Sub"));

        for (int i=0; i<16; ++i){
            Text name = Text.literal(String.valueOf(i));
            var field = entries.startBooleanToggle(name, false).setDefaultValue(false);
            sub.add(field.build());
        }

        sub.setExpanded(true);
        main.addEntry(sub.build());
        builder.setParentScreen(parent);

        return builder.build();
    }
}
  1. Make a mod with this screen using the method of your choice. (I'm using ModMenu)
  2. Type "1" in the search bar. This will filter out roughly half of the entries.
  3. Try toggling all visible entries exactly once. You should only be able to toggle entry 10.
  4. You should be able to find some clickable areas on the backgorund past the last visible entries.
  5. Clear the search bar. You should find some of the previously hidden entries have been toggled.

I'm only using one subcategory here, but things can get wilder when there are multiple involved. The result can vary widely depending on small things, like wether subcategories were unwrapped after or before using the search field.

Mod list:

I've also reproduced this on Cloth v10 + MC1.19.4, where I'm currently developping.