mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-04 21:08:55 +08:00
Merge pull request #6783 from allenve/issue-fix
fix: issues-6779 input-formula 检索问题
This commit is contained in:
commit
c2d3d48a3c
@ -844,6 +844,27 @@ export function findTree<T extends TreeItem>(
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在树中查找节点。
|
||||
* @param tree
|
||||
* @param iterator
|
||||
*/
|
||||
export function findTreeAll<T extends TreeItem>(
|
||||
tree: Array<T>,
|
||||
iterator: (item: T, key: number, level: number, paths: Array<T>) => any
|
||||
): Array<T> {
|
||||
let result: Array<T> = [];
|
||||
|
||||
everyTree(tree, (item, key, level, paths) => {
|
||||
if (iterator(item, key, level, paths)) {
|
||||
result.push(item);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在树中查找节点, 返回下标数组。
|
||||
* @param tree
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
|
||||
import {themeable, ThemeProps, findTree} from 'amis-core';
|
||||
import {themeable, ThemeProps, findTreeAll} from 'amis-core';
|
||||
import GroupedSelection from '../GroupedSelection';
|
||||
import Tabs, {Tab} from '../Tabs';
|
||||
import TreeSelection from '../TreeSelection';
|
||||
@ -75,8 +75,8 @@ function VariableList(props: VariableListProps) {
|
||||
};
|
||||
|
||||
function onSearch(term: string) {
|
||||
const tree = findTree(list, i => ~i.label.indexOf(term));
|
||||
setFilterVars(!term ? list : tree ? [tree] : []);
|
||||
const tree = findTreeAll(list, i => ~i.label.indexOf(term));
|
||||
setFilterVars(!term ? list : tree);
|
||||
}
|
||||
|
||||
function renderSearchBox() {
|
||||
|
Loading…
Reference in New Issue
Block a user