Skip to content

Commit

Permalink
Merge pull request arco-design#74 from arco-design/fix/tree-select-fi…
Browse files Browse the repository at this point in the history
…lter

fix: tree-select filter error
  • Loading branch information
PengJiyuan authored Oct 29, 2021
2 parents a1bd59f + 7c86e9e commit 970bace
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions components/TreeSelect/tree-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,19 @@ const TreeSelect: ForwardRefRenderFunction<
}, [inputValue]);

const searchKeys = useMemo<string[]>(() => {
const newKeys = new Set(hitKeys);
let newKeys: string[] = [];
if (inputValue) {
for (const key in key2nodeProps) {
const item = key2nodeProps[key];

if (newKeys.has(key)) {
item.pathParentKeys.forEach((_key) => newKeys.add(_key));
} else if (newKeys.has(item.parentKey)) {
newKeys.add(key);
const pathKeys = [...item.pathParentKeys, key];

if (pathKeys.some((_key) => hitKeys && hitKeys.has(_key))) {
newKeys = newKeys.concat(pathKeys);
}
}
}
return Array.from(newKeys);
return Array.from(new Set(newKeys));
}, [inputValue, key2nodeProps, hitKeys]);

useEffect(() => {
Expand Down

0 comments on commit 970bace

Please sign in to comment.