Bug: Code Connect getSlot() returns the wrong layer on component instances
Summary
In a Code Connect template (@figma/code-connect 2.0.1, React, parserless template), instance.getSlot('<name>') returns the correct slot on a main component but the wrong layer on any instance of it. On instances, the result is shifted to an earlier layer in the tree.
Steps to reproduce
1. Create a component with these direct children, in this order: rectangle "R1", rectangle "R2", slot "One" (containing a frame "OneKid"), slot "Two" (containing a frame "TwoKid"). No variants.
2. Publish this template for the component:
import figma from 'figma';
const instance = figma.selectedInstance;
export default {
id: 'SlotTest',
example: figma.code`<SlotTest first={<>${instance.getSlot('One')}</>} second={<>${instance.getSlot('Two')}</>} />`,
};
3. Place an instance of the component.
4. Inspect the main component and the instance in Dev Mode.
Expected
On both the main component and the instance, "One" resolves to the One slot and "Two" resolves to the Two slot.
Actual
- Main component: first = One, second = Two (correct).
- Instance: first = R1, second = One (wrong).
A variation with the first slot nested inside a frame (R1, R2, Wrap > slot "Inner", slot "Outer") gives Inner -> R2 and Outer -> Inner on the instance, and correct results on the main component. A fresh instance, a component inside a variant set, and a plain component all behave the same way.
Impact
Instance snippets in Dev Mode show the wrong slot contents, so designers and AI tools that copy an instance get incorrect code.
Environment
- @figma/code-connect 2.0.1
- Figma design file, Dev Mode, macOS
- Reproduced 2026-10-17
