Merge pull request #7174 from 2betop/fix-select-tree-mode

fix: 修复 select 的 tree 模式点击搜索结果无效果问题 Close: #7173
This commit is contained in:
hsm-lv 2023-06-16 13:19:16 +08:00 committed by GitHub
commit 5037c0bfda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -324,8 +324,9 @@ export class Transfer<
// 树搜索处理
@autobind
handleSearchTreeChange(values: Array<Option>, searchOptions: Array<Option>) {
const {onChange, value, valueField = 'value'} = this.props;
const {onChange, value, valueField = 'value', multiple} = this.props;
const searchAvailableOptions = this.getFlattenArr(searchOptions);
values = Array.isArray(values) ? values : values ? [values] : [];
const useArr = intersectionWith(
searchAvailableOptions,
@ -339,12 +340,14 @@ export class Transfer<
);
const newArr: Array<Option> = [];
Array.isArray(value) &&
value.forEach((item: Option) => {
if (!unuseArr.find(v => v[valueField] === item[valueField])) {
newArr.push(item);
}
});
if (multiple) {
Array.isArray(value) &&
value.forEach((item: Option) => {
if (!unuseArr.find(v => v[valueField] === item[valueField])) {
newArr.push(item);
}
});
}
useArr.forEach(item => {
if (!newArr.find(v => v[valueField] === item[valueField])) {
newArr.push(item);