Skip to content

Commit

Permalink
fix: tree-select filter error
Browse files Browse the repository at this point in the history
  • Loading branch information
yinkaihui committed Oct 29, 2021
1 parent 95b785a commit 7c86e9e
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 7c86e9e

Please sign in to comment.