metonym / svelte-typeahead

Accessible, fuzzy search typeahead component
https://metonym.github.io/svelte-typeahead
MIT License
222 stars 18 forks source link

Allow setting a threshold score for result to be considered a match #83

Open thedivtagguy opened 8 months ago

thedivtagguy commented 8 months ago

I'd like to be able to set a threshold on what is considered a match. This is what I do right now:

<Typeahead
    hideLabel
    label="Search works"
    placeholder="Try me..."
    {data}
    {extract}
    let:result
    let:value
>
    {#if result.score >= 20}
        <div>
            <strong>{getTitle(result.original)}</strong>
        </div>
    {/if}
</Typeahead>

This kinda works, but I still see empty boxes where the results below threshold are: image

Allowing for something like this to be set so only very close matches are shown would be nice.