Skip to content

Commit

Permalink
Fix Select deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
e1emeb0t committed Jun 29, 2017
1 parent ce99ecf commit 90726da
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "element-react",
"version": "1.0.15",
"version": "1.0.16",
"description": "Element UI for React",
"private": false,
"main": "dist/npm/es5/index.js",
Expand Down Expand Up @@ -48,7 +48,7 @@
"enzyme": "^2.9.1",
"eslint": "^3.19.0",
"eslint-config-airbnb": "^15.0.1",
"eslint-plugin-flowtype": "^2.34.0",
"eslint-plugin-flowtype": "^2.34.1",
"eslint-plugin-import": "^2.6.0",
"eslint-plugin-jsx-a11y": "^5.1.0",
"eslint-plugin-react": "^7.0.1",
Expand All @@ -67,7 +67,7 @@
"react-test-renderer": "^15.5.4",
"regenerator-runtime": "^0.10.5",
"sass-loader": "^6.0.5",
"sinon": "^2.3.4",
"sinon": "^2.3.6",
"style-loader": "^0.18.2",
"typescript": "^2.4.1",
"url-loader": "^0.5.8",
Expand Down
22 changes: 15 additions & 7 deletions src/select/Select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,7 @@ class Select extends Component {
return value.indexOf(curr.props.value) > -1 ? prev.concat(curr) : prev;
}, [])
}, () => {
this.resetInputHeight();
this.onSelectedChange(this.state.selected);
this.onSelectedChange(this.state.selected, false);
});
} else {
const selected = options.filter(option => {
Expand Down Expand Up @@ -287,7 +286,16 @@ class Select extends Component {

onValueChange(val: mixed) {
const { multiple } = this.props;
let { options, valueChangeBySelected, selectedInit, selected, selectedLabel, currentPlaceholder, cachedPlaceHolder } = this.state;

let {
options,
valueChangeBySelected,
selectedInit,
selected,
selectedLabel,
currentPlaceholder,
cachedPlaceHolder
} = this.state;

if (valueChangeBySelected) {
return this.setState({
Expand All @@ -303,7 +311,7 @@ class Select extends Component {
currentPlaceholder = cachedPlaceHolder;

val.forEach(item => {
let option = this.options.filter(option => option.props.value === item)[0];
let option = options.filter(option => option.props.value === item)[0];
if (option) {
this.addOptionToValue(option);
}
Expand All @@ -326,7 +334,7 @@ class Select extends Component {
});
}

onSelectedChange(val: any) {
onSelectedChange(val: any, bubble: boolean = true) {
const { multiple, filterable, onChange } = this.props;
let { query, hoverIndex, inputLength, selectedInit, currentPlaceholder, cachedPlaceHolder, valueChangeBySelected } = this.state;

Expand All @@ -343,7 +351,7 @@ class Select extends Component {

valueChangeBySelected = true;

onChange && onChange(val.map(item => item.props.value), val);
bubble && onChange && onChange(val.map(item => item.props.value), val);

// this.dispatch('form-item', 'el.form.change', val);

Expand All @@ -367,7 +375,7 @@ class Select extends Component {
});
}

onChange && onChange(val.props.value, val);
bubble && onChange && onChange(val.props.value, val);
}
}

Expand Down

0 comments on commit 90726da

Please sign in to comment.