From 0465a19c95b795ea820dc35e09b0bb56a5bfab5f Mon Sep 17 00:00:00 2001 From: alan-cruz2 Date: Fri, 25 Aug 2017 13:40:45 -0700 Subject: [PATCH] Fix to exclude `onChange` from getting passed on `...rest` Tag v0.6.2 Update acknowledgements setMuiComponent_autoComplete 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. Merge pull request #2 from alan-cruz2/patch-1 setMuiComponent_autoComplete Merge pull request #1 from alan-cruz2/using_setValue_autocomplete setting value of auto complete Update FormsyAutoComplete.jsx Update FormsyAutoComplete.jsx Merge pull request #3 from alan-cruz2/adding-back-setState Update FormsyAutoComplete.jsx --- README.md | 2 +- package.json | 2 +- src/FormsyAutoComplete.jsx | 10 +++------- src/FormsySelect.jsx | 1 + 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index fbbd789..5eaf8cf 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ See [CHANGELOG.md](https://github.com/mbrookes/formsy-material-ui/blob/master/CH ## Acknowledgements -Originally based on an example by [Ryan Blakeley](https://github.com/rojobuffalo). +Originally started by [Matt Brookes](https://github.com/mbrookes) and later transfered. Thanks to our [contributors](https://github.com/mbrookes/formsy-material-ui/graphs/contributors). diff --git a/package.json b/package.json index 602b1e6..bc2f6c0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "formsy-material-ui", - "version": "0.6.1", + "version": "0.6.2", "description": "A formsy-react compatibility wrapper for Material-UI form components.", "main": "./lib/index.js", "scripts": { diff --git a/src/FormsyAutoComplete.jsx b/src/FormsyAutoComplete.jsx index bc50e1d..c24864f 100644 --- a/src/FormsyAutoComplete.jsx +++ b/src/FormsyAutoComplete.jsx @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'; import keycode from 'keycode'; import Formsy from 'formsy-react'; import AutoComplete from 'material-ui/AutoComplete'; -import { setMuiComponentAndMaybeFocus } from 'formsy-react/src/utils'; +import { setMuiComponentAndMaybeFocus } from './utils'; const FormsyAutoComplete = createClass({ @@ -39,16 +39,12 @@ const FormsyAutoComplete = createClass({ }, handleChange: function handleChange(event) { - this.setState({ - value: event.currentTarget.value, - }); + this.setState({ value: event.currentTarget.value }, () => this.setValue(event.currentTarget.value)); if (this.props.onChange) this.props.onChange(event); }, handleUpdateInput: function handleUpdateInput(value) { - this.setState({ - value, - }); + this.setState({ value }, () => this.setValue(value)); if (this.props.onChange) this.props.onChange(null, value); }, diff --git a/src/FormsySelect.jsx b/src/FormsySelect.jsx index 136d55a..6570e89 100644 --- a/src/FormsySelect.jsx +++ b/src/FormsySelect.jsx @@ -45,6 +45,7 @@ const FormsySelect = createClass({ validationError, // eslint-disable-line no-unused-vars validationErrors, // eslint-disable-line no-unused-vars value: valueProp, + onChange, ...rest } = this.props;