-const getTagValues = (tagName: string, vocabulary: Vocabulary) => {
- const tag = vocabulary.tags[tagName];
- return tag && tag.values ? tag.values : [];
+// Attempts to match a manually typed value label with a value ID, when the user
+// doesn't select the value from the suggestions list.
+const handleBlur = (
+ { dispatch }: WrappedFieldMetaProps,
+ { onBlur, value }: WrappedFieldInputProps,
+ vocabulary: Vocabulary,
+ tagKeyID: string) =>
+ () => {
+ dispatch(change(COLLECTION_TAG_FORM_NAME, PROPERTY_VALUE_FIELD_ID, getTagValueID(tagKeyID, value, vocabulary)));
+ onBlur(value);
+ };
+
+// When selecting a property value, 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_VALUE_FIELD_ID, item.id));
+ };