AI-native design editor. Open-source Figma alternative.
Fix override resolution for nested instance targets
Danila Poyarkovefdb09852fcd
diff --git a/packages/core/src/kiwi/instance-overrides.ts b/packages/core/src/kiwi/instance-overrides.tsindex 47637d4f0..a3066737d 100644--- a/packages/core/src/kiwi/instance-overrides.ts+++ b/packages/core/src/kiwi/instance-overrides.ts@@ -70,15 +70,19 @@ export function populateAndApplyOverrides(return root}- function findDescendantByComponentId(parentId: string, componentId: string): string | null {+ function findNodeByComponentId(parentId: string, componentId: string): string | null {const targetRoot = getComponentRoot(componentId)const parent = graph.getNode(parentId)if (!parent) return null+ // Check direct children first, then recursefor (const childId of parent.childIds) {const child = graph.getNode(childId)if (!child) continue+ if (child.componentId === componentId) return childIdif (child.componentId && getComponentRoot(child.componentId) === targetRoot) return childId- const deep = findDescendantByComponentId(childId, componentId)+ }+ for (const childId of parent.childIds) {+ const deep = findNodeByComponentId(childId, componentId)if (deep) return deep}return null@@ -91,7 +95,15 @@ export function populateAndApplyOverrides(const figmaGuid = overrideKeyToGuid.get(key) ?? keyconst remapped = guidToNodeId.get(figmaGuid)if (!remapped) return null- const found = findDescendantByComponentId(currentId, remapped)++ // The override may target the current node itself (when it's an instance+ // cloned from the component the override points to)+ const current = graph.getNode(currentId)+ if (current?.componentId === remapped) {+ continue+ }++ const found = findNodeByComponentId(currentId, remapped)if (!found) return nullcurrentId = found}