OdinSelector<T> search issue

Issue #962 open
Gamer XP created an issue

Description

When selector contains Values with other Values inside of them (so, not empty folders), and you find those folder-values with search - it displays contents of the “folder”. And if those children satisfy search term - it will also display them separately below.

Main issue is that element inside folder are often can’t be clicked. Another is that child element may not satisfy search term, but still be displayed.

Example

Here I’m trying to click elements, but it does not work for some of them:

https://gyazo.com/fc45c1cc20a22e1ca431db0440ff1afb

Workaround

For now, workaround I’ve found is to NOT display duplicate items - then selection works fine. Did it like this:

HashSet<OdinMenuItem> addedItems = new HashSet<OdinMenuItem>();

selector.SelectionTree.Config.SearchFunction = _item =>
{
    if (selector.SelectionTree.FlatMenuTree.Count == 0) 
        addedItems.Clear();

    if (addedItems.Contains(_item))
        return false;

    var term = selector.SelectionTree.Config.SearchTerm;
    if (!FuzzySearch.Contains(term, _item.SearchString))
        return false;

    foreach (OdinMenuItem child in _item.GetChildMenuItemsRecursive(true))
    {
        addedItems.Add(child);
    }

    return true;
};

Desired solution

I expect child element to be not drawn for found element unless they satisfy search results

Comments (1)

  1. Log in to comment