From fe05a06e7db055e1935525be7562d41d87dfd3d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=8E=E4=BD=8D?= Date: Fri, 30 Mar 2018 15:39:05 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B6=E9=83=A8=E6=90=9C=E7=B4=A2=E6=A1=86?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E6=B7=BB=E5=8A=A0=E9=BB=98=E8=AE=A4=E6=89=93?= =?UTF-8?q?=E5=BC=80=E9=85=8D=E7=BD=AE=20(#1179)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 顶部搜索框组件添加输入框的常开和首次打开配置 * 顶部搜索框组件移除常开配置,重命名默认打开配置 --- src/components/HeaderSearch/index.js | 5 ++++- src/components/HeaderSearch/index.md | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/HeaderSearch/index.js b/src/components/HeaderSearch/index.js index 49b9072f..295a837a 100644 --- a/src/components/HeaderSearch/index.js +++ b/src/components/HeaderSearch/index.js @@ -12,6 +12,7 @@ export default class HeaderSearch extends PureComponent { className: '', placeholder: '', dataSource: [], + defaultOpen: false, }; static propTypes = { className: PropTypes.string, @@ -20,9 +21,10 @@ export default class HeaderSearch extends PureComponent { onPressEnter: PropTypes.func, defaultActiveFirstOption: PropTypes.bool, dataSource: PropTypes.array, + defaultOpen: PropTypes.bool, }; state = { - searchMode: false, + searchMode: this.props.defaultOpen, value: '', }; componentWillUnmount() { @@ -56,6 +58,7 @@ export default class HeaderSearch extends PureComponent { }; render() { const { className, placeholder, ...restProps } = this.props; + delete restProps.defaultOpen; // for rc-select not affected const inputClass = classNames(styles.input, { [styles.show]: this.state.searchMode, }); diff --git a/src/components/HeaderSearch/index.md b/src/components/HeaderSearch/index.md index 5c8fd701..3d4d3c22 100644 --- a/src/components/HeaderSearch/index.md +++ b/src/components/HeaderSearch/index.md @@ -18,3 +18,4 @@ dataSource | 当前提示内容列表 | string[] | - onSearch | 选择某项或按下回车时的回调 | function(value) | - onChange | 输入搜索字符的回调 | function(value) | - onPressEnter | 按下回车时的回调 | function(value) | - +defaultOpen | 输入框首次显示是否打开 | boolean | false -- GitLab