diff --git a/desktop/plugins/public/ui-debugger/index.tsx b/desktop/plugins/public/ui-debugger/index.tsx index 0df383cbc..b7a905504 100644 --- a/desktop/plugins/public/ui-debugger/index.tsx +++ b/desktop/plugins/public/ui-debugger/index.tsx @@ -128,8 +128,9 @@ export function plugin(client: PluginClient) { } event.nodes.forEach((node) => { - draft.nodes.set(node.id, node); + draft.nodes.set(node.id, {...node}); }); + setParentPointers(rootId.get()!!, undefined, draft.nodes); }); uiState.treeState.update((draft) => { @@ -164,6 +165,21 @@ export function plugin(client: PluginClient) { }; } +function setParentPointers( + cur: Id, + parent: Id | undefined, + nodes: Map, +) { + const node = nodes.get(cur); + if (node == null) { + return; + } + node.parent = parent; + node.children.forEach((child) => { + setParentPointers(child, cur, nodes); + }); +} + function collapseinActiveChildren(node: UINode, draft: TreeState) { if (node.activeChild) { const inactiveChildren = node.children.filter( diff --git a/desktop/plugins/public/ui-debugger/types.tsx b/desktop/plugins/public/ui-debugger/types.tsx index d1df5635b..6af2e113d 100644 --- a/desktop/plugins/public/ui-debugger/types.tsx +++ b/desktop/plugins/public/ui-debugger/types.tsx @@ -63,6 +63,7 @@ export type NestedNode = { export type UINode = { id: Id; + parent?: Id; //this attribute doesn't come from the client and is set by the desktop qualifiedName: string; name: string; attributes: Record;