fix: throughCollection support fuzzy search (#3949)

This commit is contained in:
katherinehhh 2024-04-07 09:53:53 +08:00 committed by GitHub
parent 47dffe55b5
commit 04b6d79dcb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -326,13 +326,13 @@ export const ThroughCollection = observer(
} }
}, []); }, []);
const handleSearch = (value: string) => { const handleSearch = (value: string) => {
const data = loadCollections();
if (value) { if (value) {
const filteredOptions = options.filter((option) => { const filteredOptions = data.filter((option) => {
return option.label.toLowerCase().includes(value.toLowerCase()); return option.label.toLowerCase().includes(value.toLowerCase());
}); });
setOptions(filteredOptions); setOptions(filteredOptions);
} else { } else {
const data = loadCollections();
setOptions(data); setOptions(data);
} }
}; };