Skip to content

AI-native design editor. Open-source Figma alternative.

Fix DSD resolution for swapped instance children

Danila Poyarkovd93c4752cb2e
diff --git a/packages/core/src/kiwi/instance-overrides/resolve.ts b/packages/core/src/kiwi/instance-overrides/resolve.ts
index b4522d416..b03189646 100644
--- a/packages/core/src/kiwi/instance-overrides/resolve.ts
+++ b/packages/core/src/kiwi/instance-overrides/resolve.ts
@@ -129,8 +129,21 @@ export function resolveOverrideTarget(ctx: OverrideContext, instanceId: string,
if (current?.componentId === remapped) continue
const found = findNodeByComponentId(ctx, currentId, remapped)
- if (!found) return null
- currentId = found
+ if (found) {
+ currentId = found
+ continue
+ }
+
+ // After an instance swap, the child's componentId points to the new
+ // component, not the one referenced by the guidPath. Fall back to the
+ // single child of a swapped instance — it occupies the same slot.
+ const parent = ctx.graph.getNode(currentId)
+ if (parent?.childIds.length === 1) {
+ currentId = parent.childIds[0]
+ continue
+ }
+
+ return null
}
return currentId
}