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 { ...@@ -11,6 +11,7 @@ export default class HeaderSearch extends PureComponent {
className: PropTypes.string, className: PropTypes.string,
placeholder: PropTypes.string, placeholder: PropTypes.string,
onSearch: PropTypes.func, onSearch: PropTypes.func,
onChange: PropTypes.func,
onPressEnter: PropTypes.func, onPressEnter: PropTypes.func,
defaultActiveFirstOption: PropTypes.bool, defaultActiveFirstOption: PropTypes.bool,
dataSource: PropTypes.array, dataSource: PropTypes.array,
...@@ -22,6 +23,7 @@ export default class HeaderSearch extends PureComponent { ...@@ -22,6 +23,7 @@ export default class HeaderSearch extends PureComponent {
defaultActiveFirstOption: false, defaultActiveFirstOption: false,
onPressEnter: () => {}, onPressEnter: () => {},
onSearch: () => {}, onSearch: () => {},
onChange: () => {},
className: '', className: '',
placeholder: '', placeholder: '',
dataSource: [], dataSource: [],
...@@ -61,9 +63,12 @@ export default class HeaderSearch extends PureComponent { ...@@ -61,9 +63,12 @@ export default class HeaderSearch extends PureComponent {
}; };
onChange = value => { onChange = value => {
const { onChange } = this.props; const { onSearch, onChange } = this.props;
this.setState({ value }); this.setState({ value });
if (onChange) { if (onSearch){
onSearch(value);
}
if (onChange){
onChange(value); 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