Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing some issues with AutoComplete #231

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
alan-cruz2 committed Aug 25, 2017
commit 0465a19c95b795ea820dc35e09b0bb56a5bfab5f
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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).

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": {
10 changes: 3 additions & 7 deletions src/FormsyAutoComplete.jsx
Original file line number Diff line number Diff line change
@@ -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);
},

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