janosh / svelte-multiselect

Keyboard-friendly, accessible and highly customizable multi-select component
https://multiselect.janosh.dev
MIT License
287 stars 36 forks source link

Add prop for custom filtering #28

Closed failpark closed 2 years ago

failpark commented 2 years ago

In my case, I need to filter, in addition to label, for some other field in Options.

janosh commented 2 years ago

Could you describe your use case in more detail? Are you proposing a function as a new prop that receives each option object and returns a boolean whether to include it in the filtered list?

failpark commented 2 years ago

I made a PR with an Example. Hope that explains it :sweat_smile:

failpark commented 2 years ago

You could now search for JavaScript in the first MultiSelect and you would now see all JavaScript frameworks (Svelte, React, Vue, etc.) svelte-select has the same thing https://github.com/rob-balfre/svelte-select#exposed-methods but there its called itemFilter