Commit 13725bcf authored by 低位's avatar 低位 Committed by ddcat1115

顶部搜索框组件添加默认打开配置 (#1179)

* 顶部搜索框组件添加输入框的常开和首次打开配置

* 顶部搜索框组件移除常开配置,重命名默认打开配置
parent 6b7b4542
...@@ -12,6 +12,7 @@ export default class HeaderSearch extends PureComponent { ...@@ -12,6 +12,7 @@ export default class HeaderSearch extends PureComponent {
className: '', className: '',
placeholder: '', placeholder: '',
dataSource: [], dataSource: [],
defaultOpen: false,
}; };
static propTypes = { static propTypes = {
className: PropTypes.string, className: PropTypes.string,
...@@ -20,9 +21,10 @@ export default class HeaderSearch extends PureComponent { ...@@ -20,9 +21,10 @@ export default class HeaderSearch extends PureComponent {
onPressEnter: PropTypes.func, onPressEnter: PropTypes.func,
defaultActiveFirstOption: PropTypes.bool, defaultActiveFirstOption: PropTypes.bool,
dataSource: PropTypes.array, dataSource: PropTypes.array,
defaultOpen: PropTypes.bool,
}; };
state = { state = {
searchMode: false, searchMode: this.props.defaultOpen,
value: '', value: '',
}; };
componentWillUnmount() { componentWillUnmount() {
...@@ -56,6 +58,7 @@ export default class HeaderSearch extends PureComponent { ...@@ -56,6 +58,7 @@ export default class HeaderSearch extends PureComponent {
}; };
render() { render() {
const { className, placeholder, ...restProps } = this.props; const { className, placeholder, ...restProps } = this.props;
delete restProps.defaultOpen; // for rc-select not affected
const inputClass = classNames(styles.input, { const inputClass = classNames(styles.input, {
[styles.show]: this.state.searchMode, [styles.show]: this.state.searchMode,
}); });
......
...@@ -18,3 +18,4 @@ dataSource | 当前提示内容列表 | string[] | - ...@@ -18,3 +18,4 @@ dataSource | 当前提示内容列表 | string[] | -
onSearch | 选择某项或按下回车时的回调 | function(value) | - onSearch | 选择某项或按下回车时的回调 | function(value) | -
onChange | 输入搜索字符的回调 | function(value) | - onChange | 输入搜索字符的回调 | function(value) | -
onPressEnter | 按下回车时的回调 | function(value) | - onPressEnter | 按下回车时的回调 | function(value) | -
defaultOpen | 输入框首次显示是否打开 | boolean | false
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