From cbd7491e633f465fa36fc1ebbbd7baf56bec1437 Mon Sep 17 00:00:00 2001 From: Zuzana Odstrcilova Date: Wed, 1 Jul 2026 10:01:55 +0200 Subject: [PATCH] fix: derive {component} key placeholder from instances Text nodes inside a component instance did not resolve the {component} placeholder because getAllParents only matched COMPONENT / COMPONENT_SET parents, not INSTANCE. Keys generated for instances lost the component name (e.g. "-log-in" instead of "component-log-in"). Now when an INSTANCE parent is encountered, resolve its main component (using the component set name when the main component is a variant). Co-Authored-By: Claude Opus 4.8 (1M context) --- src/main/utils/nodeParents.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/utils/nodeParents.ts b/src/main/utils/nodeParents.ts index 3fdcbcc..bc77dd4 100644 --- a/src/main/utils/nodeParents.ts +++ b/src/main/utils/nodeParents.ts @@ -35,6 +35,17 @@ export function getAllParents(nodeId: string): NodeParents { !result.component ) { result.component = parent; + } else if (parent.type === "INSTANCE" && !result.component) { + // For an instance, resolve the main component it was created from. + // If that component is a variant inside a component set, use the set + // so the key gets the recognizable component name (e.g. "Button"). + const mainComponent = parent.mainComponent; + if (mainComponent) { + result.component = + mainComponent.parent?.type === "COMPONENT_SET" + ? (mainComponent.parent as ComponentSetNode) + : mainComponent; + } } else if (parent.type === "SECTION" && !result.section) { result.section = parent; } else if (parent.type === "GROUP" && !result.group) {