add
This commit is contained in:
parent
6b699a4092
commit
3499231119
|
@ -72,7 +72,7 @@ export default function TermSelect({
|
|||
throw error;
|
||||
}
|
||||
},
|
||||
[utils]
|
||||
[utils, value]
|
||||
);
|
||||
|
||||
const fetchTerms = useCallback(async () => {
|
||||
|
@ -139,25 +139,35 @@ export default function TermSelect({
|
|||
}
|
||||
};
|
||||
|
||||
const handleExpand = async (keys: React.Key[]) => {
|
||||
try {
|
||||
const allKeyIds =
|
||||
keys.map((key) => key.toString()).filter(Boolean) || [];
|
||||
const expandedNodes = await utils.term.getChildSimpleTree.fetch({
|
||||
termIds: allKeyIds,
|
||||
taxonomyId,
|
||||
domainId,
|
||||
});
|
||||
const flattenedNodes = expandedNodes.flat();
|
||||
const newItems = getUniqueItems(
|
||||
[...listTreeData, ...flattenedNodes],
|
||||
"id"
|
||||
);
|
||||
setListTreeData(newItems);
|
||||
} catch (error) {
|
||||
console.error("Error expanding nodes with keys", keys, ":", error);
|
||||
}
|
||||
};
|
||||
const handleExpand = useCallback(
|
||||
async (keys: React.Key[]) => {
|
||||
try {
|
||||
const allKeyIds =
|
||||
keys.map((key) => key.toString()).filter(Boolean) || [];
|
||||
const expandedNodes = await utils.term.getChildSimpleTree.fetch(
|
||||
{
|
||||
termIds: allKeyIds,
|
||||
taxonomyId,
|
||||
domainId,
|
||||
}
|
||||
);
|
||||
const flattenedNodes = expandedNodes.flat();
|
||||
const newItems = getUniqueItems(
|
||||
[...listTreeData, ...flattenedNodes],
|
||||
"id"
|
||||
);
|
||||
setListTreeData(newItems);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
"Error expanding nodes with keys",
|
||||
keys,
|
||||
":",
|
||||
error
|
||||
);
|
||||
}
|
||||
},
|
||||
[value]
|
||||
);
|
||||
const handleDropdownVisibleChange = async (open: boolean) => {
|
||||
if (open) {
|
||||
// This will attempt to expand all nodes and fetch their children when the dropdown opens
|
||||
|
|
Loading…
Reference in New Issue