Open rjworks opened 3 years ago
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.
fuzzy search.js:
SelectSearch
It only filters the group name, and not the items within the group