Skip to content

Commit

Permalink
Fix to exclude onChange from getting passed on ...rest
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alan-cruz2 committed Aug 25, 2017
1 parent 885edc3 commit 0465a19
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
10 changes: 3 additions & 7 deletions src/FormsyAutoComplete.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({

Expand Down Expand Up @@ -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);
},

Expand Down
1 change: 1 addition & 0 deletions src/FormsySelect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 0465a19

Please sign in to comment.