-const PropertyValueInput = ({ input, meta, vocabulary, propertyKey }: WrappedFieldProps & PropertyValueFieldProps) =>
- <Autocomplete
- value={input.value}
- onChange={input.onChange}
- label='Value'
- suggestions={getSuggestions(input.value, propertyKey, vocabulary)}
- items={ITEMS_PLACEHOLDER}
- onSelect={input.onChange}
- renderSuggestion={identity}
- error={meta.invalid}
- helperText={meta.error}
- />;
+const PropertyValueInput = ({ vocabulary, propertyKeyId, propertyKeyName, ...props }: WrappedFieldProps & PropertyValueFieldProps) =>
+ <FormName children={data => (
+ <Autocomplete
+ label='Value'
+ disabled={props.disabled}
+ suggestions={getSuggestions(props.input.value, propertyKeyId, vocabulary)}
+ onSelect={handleSelect(PROPERTY_VALUE_FIELD_ID, data.form, props.input, props.meta)}
+ onBlur={() => {
+ // Case-insensitive search for the value in the vocabulary
+ const foundValueID = getTagValueID(propertyKeyId, props.input.value, vocabulary);
+ if (foundValueID !== '') {
+ props.input.value = getTagValueLabel(propertyKeyId, foundValueID, vocabulary);
+ }
+ handleBlur(PROPERTY_VALUE_FIELD_ID, data.form, props.meta, props.input, foundValueID)();
+ }}
+ onChange={(e: ChangeEvent<HTMLInputElement>) => {
+ const newValue = e.currentTarget.value;
+ const tagValueID = getTagValueID(propertyKeyId, newValue, vocabulary);
+ handleChange(data.form, tagValueID, props.input, props.meta, newValue);
+ }}
+ {...buildProps(props)}
+ />
+ )} />;