Commit 31d63bc7 authored by Yanghc's avatar Yanghc Committed by 陈帅

修复 HeaderSearch 的 onSearch 回调 (#3227)

* 修复 HeaderSearch 的 onSearch 回调

修复 #3222  问题,在使用 HeaderSearch组件时,可以选择使用 `onSearch` 或者 `onChange ` 方法。

* 统一代码格式
parent c46c6e13
......@@ -11,6 +11,7 @@ export default class HeaderSearch extends PureComponent {
className: PropTypes.string,
placeholder: PropTypes.string,
onSearch: PropTypes.func,
onChange: PropTypes.func,
onPressEnter: PropTypes.func,
defaultActiveFirstOption: PropTypes.bool,
dataSource: PropTypes.array,
......@@ -22,6 +23,7 @@ export default class HeaderSearch extends PureComponent {
defaultActiveFirstOption: false,
onPressEnter: () => {},
onSearch: () => {},
onChange: () => {},
className: '',
placeholder: '',
dataSource: [],
......@@ -61,10 +63,13 @@ export default class HeaderSearch extends PureComponent {
};
onChange = value => {
const { onChange } = this.props;
const { onSearch, onChange } = this.props;
this.setState({ value });
if (onChange) {
onChange(value);
if (onSearch){
onSearch(value);
}
if (onChange){
onChange(value);
}
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment