Extract property field props builder
[arvados-workbench2.git] / src / views-components / resource-properties-form / property-key-field.tsx
index 85cc07f6dedf6baab15f2525463aeecc177cb296..18be627e025d29f9eebe3a5514d246cdb27d2ff3 100644 (file)
@@ -8,7 +8,7 @@ import { identity, memoize } from 'lodash';
 import { Autocomplete } from '~/components/autocomplete/autocomplete';
 import { Vocabulary } from '~/models/vocabulary';
 import { require } from '~/validators/require';
-import { ITEMS_PLACEHOLDER, connectVocabulary, VocabularyProp, hasError, getErrorMsg, handleBlur } from '~/views-components/resource-properties-form/property-field-common';
+import { ITEMS_PLACEHOLDER, connectVocabulary, VocabularyProp, hasError, getErrorMsg, handleBlur, buildProps } from '~/views-components/resource-properties-form/property-field-common';
 
 export const PROPERTY_KEY_FIELD_NAME = 'key';
 
@@ -20,18 +20,11 @@ export const PropertyKeyField = connectVocabulary(
             vocabulary={vocabulary}
             validate={getValidation(vocabulary)} />);
 
-const PropertyKeyInput = ({ input, meta, vocabulary }: WrappedFieldProps & VocabularyProp) =>
+const PropertyKeyInput = ({ vocabulary, ...props }: WrappedFieldProps & VocabularyProp) =>
     <Autocomplete
-        value={input.value}
-        onChange={input.onChange}
-        onBlur={handleBlur(input)}
         label='Key'
-        suggestions={getSuggestions(input.value, vocabulary)}
-        items={ITEMS_PLACEHOLDER}
-        onSelect={input.onChange}
-        renderSuggestion={identity}
-        error={hasError(meta)}
-        helperText={getErrorMsg(meta)}
+        suggestions={getSuggestions(props.input.value, vocabulary)}
+        {...buildProps(props)}
     />;
 
 const getValidation = memoize(