Merge pull request #6783 from allenve/issue-fix

fix: issues-6779 input-formula 检索问题
This commit is contained in:
Allen 2023-05-05 15:48:30 +08:00 committed by GitHub
commit c2d3d48a3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 3 deletions

View File

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

View File

@ -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() {