-const getSuggestions = (value: string, vocabulary: Vocabulary) =>
- getTags(vocabulary).filter(tag => tag.label.toLowerCase().includes(value.toLowerCase()));
-
-// Attempts to match a manually typed key label with a key ID, when the user
-// doesn't select the key from the suggestions list.
-const handleBlur = (
- { dispatch }: WrappedFieldMetaProps,
- { onBlur, value }: WrappedFieldInputProps,
- vocabulary: Vocabulary) =>
- () => {
- dispatch(change(COLLECTION_TAG_FORM_NAME, PROPERTY_KEY_FIELD_ID, getTagKeyID(value, vocabulary)));
- onBlur(value);
- };
-
-// When selecting a property key, save its ID for later usage.
-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);