-const getSuggestions = (value: string, vocabulary: Vocabulary) =>
- getTagsList(vocabulary).filter(tag => tag.label.toLowerCase().includes(value.toLowerCase()));
-
-const getTagsList = ({ tags }: Vocabulary) => {
- const ret = tags && Object.keys(tags)
- ? Object.keys(tags).map(
- tagID => tags[tagID].labels
- ? {"id": tagID, "label": tags[tagID].labels[0].label}
- : {"id": tagID, "label": tagID})
- : [];
- return ret;
-};
-
-const handleSelect = (
- { onChange }: WrappedFieldInputProps,
- { dispatch }: WrappedFieldMetaProps) => {
- return (item:PropFieldSuggestion) => {
- onChange(item.label);
- dispatch(change(COLLECTION_TAG_FORM_NAME, PROPERTY_KEY_FIELD_ID, item.id));
- };
+const getSuggestions = (value: string, vocabulary: Vocabulary) => {
+ const re = new RegExp(escapeRegExp(value), "i");
+ return getTags(vocabulary).filter(tag => re.test(tag.label) && tag.label !== value);