react-select-search
react-select-search copied to clipboard
search not working in groups
fuzzy search.js:
// eslint-disable-next-line import/no-extraneous-dependencies
import Fuse from 'fuse.js';
export default function fuzzySearch(options) {
const fuse = new Fuse(options, {
keys: ['name', 'value', 'items.name', 'items.value'],
threshold: 0.3,
});
console.log(fuse)
return (value) => {
if (!value.length) {
return options;
}
return fuse.search(value);
};
}
SelectSearch
<SelectSearch
options={options}
value={value}
onChange={setValue}
search={true}
emptyMessage="Not found"
placeholder="Try COSC 111"
printOptions="always"
autoFocus={true}
autoComplete={'off'}
filterOptions={fuzzySearch}
/>
It only filters the group name, and not the items within the group
have the same issue, here is something similar but does not solve our problem https://github.com/tbleckert/react-select-search/issues/181
I eventually went with react-select as this did everything.