From f6700741007132e11108e3c84056795e3616530c Mon Sep 17 00:00:00 2001 From: alan-cruz2 Date: Thu, 10 Aug 2017 17:21:48 -0700 Subject: [PATCH] setting value of auto complete Addresses two problems: - If using FormsyAutoComplete a user begins to type and uses the keyboard to select the first option in the AutoComplete menus (Keyboard, not mouse click) `handleBlur` will set `_value` before the selected autocomplete item text is set in the input. - If, for some reason, `blur` is not triggered on the AutoComplete element, an incorrect value can be set for the formsy element/model. Since there is little value of having a state attribute of `value` lets use the helper function (through the mixin) to guarantee that formsy has the most "up-to-date" value. --- src/FormsyAutoComplete.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/FormsyAutoComplete.jsx b/src/FormsyAutoComplete.jsx index bc50e1d..b9a9287 100644 --- a/src/FormsyAutoComplete.jsx +++ b/src/FormsyAutoComplete.jsx @@ -39,14 +39,14 @@ const FormsyAutoComplete = createClass({ }, handleChange: function handleChange(event) { - this.setState({ + this.setValue({ value: event.currentTarget.value, }); if (this.props.onChange) this.props.onChange(event); }, handleUpdateInput: function handleUpdateInput(value) { - this.setState({ + this.setValue({ value, }); if (this.props.onChange) this.props.onChange(null, value);