Browse Source

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

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

* 顶部搜索框组件移除常开配置,重命名默认打开配置
pull/1290/head
低位 8 years ago
committed by 陈帅
parent
commit
fe05a06e7d
  1. 5
      src/components/HeaderSearch/index.js
  2. 1
      src/components/HeaderSearch/index.md

5
src/components/HeaderSearch/index.js

@ -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 {
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 {
}; };
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,
}); });

1
src/components/HeaderSearch/index.md

@ -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

Loading…
Cancel
Save