choc-autocomplete icon indicating copy to clipboard operation
choc-autocomplete copied to clipboard

Autocomplete is showing a match if the 7 last char are equal even if the "x" other are not

Open mDeSimone-DFactorySrl opened this issue 9 months ago • 4 comments

Hi all, sorry for bad eng. My autocomplete is showing a match if a word contains the 7 chars that are at the end of the user input but it is not checking if the first one is equal. if i search "USA1234567" i will get in return any value that ends in "1234567" or any other sequence of 7 chars like:

const countries = [
        "Random1234567",
        "Qwerty1234567",
        "Azerty1234567",
        "USA1234567",
    ];

immagine

How can i return only value that strictly match at the starts? I have tryed to search in the issue but i cannot find anything

my code is:

<AutoComplete openOnFocus>
  <AutoCompleteInput variant="filled" />
    <AutoCompleteList>
        {countries.map((country, cid) => (
            <AutoCompleteItem
                key={`option-${cid}`}
                value={country}
                textTransform="capitalize"
            >
                {country}
            </AutoCompleteItem>
        ))}
    </AutoCompleteList>
  </AutoComplete>

mDeSimone-DFactorySrl avatar May 07 '24 14:05 mDeSimone-DFactorySrl

Hi @mDeSimone-DFactorySrl

What you're seeing is a result of the default filter being fuzzySearch. To get around it, you can pass in your own filter prop. I am not at a computer to give an example at the moment, but I can post one once I am back.

Kysluss avatar May 11 '24 13:05 Kysluss

Here is a link to another issue that has an example custom filter.

https://github.com/anubra266/choc-autocomplete/issues/249

Kysluss avatar May 11 '24 13:05 Kysluss

Here is a link to another issue that has an example custom filter.

https://github.com/anubra266/choc-autocomplete/issues/249

Thanks i will try :)

mDeSimone-DFactorySrl avatar May 11 '24 14:05 mDeSimone-DFactorySrl

Let me know if that works or not. I'm back now and can drum up an example.

Kysluss avatar May 12 '24 23:05 Kysluss