Skip to content

Commit

Permalink
Merge pull request #372 from youzan/hotfix/select_bugfix_20170711
Browse files Browse the repository at this point in the history
select: 修复onEmptySelected的bug
  • Loading branch information
cpylua authored Jul 11, 2017
2 parents fe2936e + 3898438 commit 51cef46
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/zent/src/select/Popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,19 @@ class Popup extends (PureComponent || Component) {
}

optionChangedHandler(ev, cid) {
let { filter, data } = this.props;
let { keyword } = this.state;
this.setState({
keyword: ''
});
this.props.onBlur();
this.props.onChange(
ev,
this.props.data.filter(item => item.cid === cid)[0]
data.filter(
item =>
(!keyword || !filter || filter(item, `${keyword}`)) &&
item.cid === cid
)[0]
);
}

Expand Down
1 change: 1 addition & 0 deletions packages/zent/src/select/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ ReactDOM.render(
data={data}
optionValue="id"
optionText="name"
onEmptySelected={(data) => console.log(data)}
filter={(item, keyword) => item.name.indexOf(keyword) > -1}
/>
, mountNode
Expand Down

0 comments on commit 51cef46

Please sign in to comment.