Skip to content

Commit fde43a1

Browse files
author
liyuan-meng
committed
🐛下拉框支持不限,问题修改
1 parent 0cb050d commit fde43a1

4 files changed

Lines changed: 26 additions & 8 deletions

File tree

src/components/select/demos/unlimited.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ desc: 基本使用
99
* title: 基本使用
1010
* desc: 多选下拉带不限
1111
*/
12-
import React, { useState } from 'react';
12+
import React, { useState, useEffect } from 'react';
1313
import { Select } from 'cloud-react';
1414

1515
const Option = Select.Option;
1616

1717
const dataList = [
1818
{
19-
label: '不限',
19+
label: '不限语言',
2020
value: '',
2121
},
2222
{
@@ -38,16 +38,22 @@ const dataList = [
3838
];
3939

4040
export default function SelectDemo() {
41-
const [v, setValue] = useState(['1', '2']);
41+
const [v, setValue] = useState([]);
4242
const [multiDataList, setDataList] = useState(dataList);
43+
44+
useEffect(() => {
45+
setTimeout(() => {
46+
setValue(['1', '2'])
47+
}, 1000)
48+
}, [])
4349
return (
4450
<div className="demo">
4551
<Select
4652
value={v}
4753
onChange={values => {
4854
setValue(values);
4955
}}
50-
style={{ width: 120 }}
56+
style={{ width: 200 }}
5157
multiple
5258
supportUnlimited
5359
unlimitedLabel="不限语言"

src/components/select/index.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@
244244
.@{select-prefix-cls}-multi-search-placeholder {
245245
position: absolute;
246246
color: rgba(0, 0, 0, 0.25);
247+
248+
.multi-unlimited {
249+
color: @gray-9;
250+
}
247251
}
248252

249253
.@{select-prefix-cls}-multiple-search-item {

src/components/select/views/multi-search.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export default function MultiSearch({
1717
setSearchStatus,
1818
disabled,
1919
searchable,
20+
supportUnlimited,
21+
unlimitedLabel,
2022
}) {
2123
const searchRef = useRef();
2224
const [selectList, setSelectList] = useState([]);
@@ -111,7 +113,13 @@ export default function MultiSearch({
111113
/>
112114
</div>
113115
)}
114-
{selectList.length || searchValue ? '' : <p className={`${selector}-multi-search-placeholder`}>{placeholder}</p>}
116+
{selectList.length || searchValue ? '' : (
117+
<p className={`${selector}-multi-search-placeholder`}>
118+
{supportUnlimited ? (
119+
<span className="multi-unlimited">{unlimitedLabel || '不限'}</span>
120+
) : placeholder}
121+
</p>
122+
)}
115123
</div>
116124
);
117125
}

src/components/select/views/selected.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ export default class Selected extends React.Component {
6161
const labels = getLables(props);
6262
this.state = {
6363
selected: labels || '',
64-
selectedList: [],
6564
clear: false,
6665
prevProps: this.props,
6766
searchValue: '',
@@ -74,7 +73,6 @@ export default class Selected extends React.Component {
7473
const labels = getLables(props);
7574
return {
7675
selected: labels || '',
77-
selectedList: props.dataSource,
7876
prevProps: props,
7977
};
8078
}
@@ -200,7 +198,9 @@ export default class Selected extends React.Component {
200198
<SearchCom
201199
placeholder={placeholder}
202200
selected={this.state.selected}
203-
selectedList={this.state.selectedList}
201+
selectedList={this.props.dataSource}
202+
unlimitedLabel={this.props.unlimitedLabel}
203+
supportUnlimited={this.props.supportUnlimited}
204204
onSearch={this.props.onSearch}
205205
open={open}
206206
searchValue={this.state.searchValue}

0 commit comments

Comments
 (0)