svelte-typeahead icon indicating copy to clipboard operation
svelte-typeahead copied to clipboard

[Feature request] Pass an Array into extract

Open Amerlander opened this issue 3 years ago • 0 comments

I think about having a title and a subtilte, which should both be searched but have different formatting.

of course I can do const extract = (item) => ' <h3>' + item.title+ '</h3><p>'+item.subtitle+'</p>':

But searching for h3 would find (and crash) the html:

image

So I thought about passing an array into extract and geting an array in result.string back:

const extract = (item) => [ item.title, item.subtitle ];
 <Typeahead {data} {extract}>
        <div>
           <h3> {result.string[0]}</h3>
           <h3> {result.string[1]}</h3>
        </div>
    </Typeahead>

What do you think about that Idea? To not break things it would be nice to have the ability to pass in an array or a string.

I think this would also need some changes in fuzzy.js, but I dind't looked much into it and thought I'll ask you first.

Amerlander avatar Feb 21 '21 19:02 Amerlander