From 981c57be178a286a13cc632765ffa2014a765aea Mon Sep 17 00:00:00 2001 From: Kilian Valkhof Date: Wed, 25 Jul 2018 12:29:02 +0200 Subject: [PATCH] Add onFocus support to TypeaheadField This resolves my issue #93. --- src/TypeaheadField.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/TypeaheadField.js b/src/TypeaheadField.js index 1736e3d..4c3ebcb 100644 --- a/src/TypeaheadField.js +++ b/src/TypeaheadField.js @@ -174,9 +174,11 @@ export class TypeaheadField extends BaseTypeaheadField { let labelKey = mapLabelKey(typeahead.labelKey); let selected = toSelected(formData, schema, typeahead.mapping, labelKey); + let onFocus = () => { this.props.onFocus($id); } let typeConf = Object.assign({}, DEFAULT_OPTIONS, typeahead, { onChange: this.handleSelectionChange(typeahead), + onFocus, labelKey, selected, }); @@ -251,11 +253,13 @@ export class AsyncTypeaheadField extends BaseTypeaheadField { asyncTypeahead.mapping, labelKey ); + let onFocus = () => { this.props.onFocus($id); } let typeConf = Object.assign({}, DEFAULT_OPTIONS, asyncTypeahead, { selected, labelKey, onChange: this.handleSelectionChange(asyncTypeahead), + onFocus, onSearch: this.handleSearch, options: this.state.options, });