Fix infinite recursion (#17609)

* fix infinite recursion

* ran eslint

---------

Co-authored-by: Brainslug <tim@brainslug.nl>
This commit is contained in:
Nitwel
2023-02-23 16:04:55 +01:00
committed by GitHub
parent ee59646b8c
commit da9c3fed3c

View File

@@ -15,6 +15,7 @@ export type FieldNode = {
type: Type;
children?: FieldNode[];
group?: boolean;
_loading?: boolean;
};
export type FieldTreeContext = {
@@ -94,7 +95,9 @@ export function useFieldTree(
if (children) {
for (const child of children) {
if (child.relatedCollection) {
child.children = getTree(child.relatedCollection, child);
child.children = [
{ name: 'Loading...', field: '', collection: '', key: '', path: '', type: 'alias', _loading: true },
];
}
}
}
@@ -192,6 +195,10 @@ export function useFieldTree(
const node = getNodeAtPath(path.split('.'), treeList.value);
if (node && node.children?.length === 1 && node.children[0]._loading) {
node.children = getTree(node.relatedCollection, node);
}
for (const child of node?.children || []) {
if (child?.relatedCollection) {
child.children = getTree(child.relatedCollection, child);