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