Plugin API: having Motion timeline open creates a hidden duplicate of the selected layer tree in page.children
I ran into some weird behavior around Figma Motion during plugin development.
Having the Motion timeline open in Figma, with any layer containing animations selected, causes that layer’s entire tree to get a hidden duplicate with a new ID. The duplicate tree only shows up in currentPage.children, not in Layers list in Figma’s UI.
Also, if the duplicated layer contains any component sets, calling getMainComponentAsync on an instance node will return a new duplicate component that’s neither part of the original or the duplicated tree. The component in both the original and duplicated tree share the component’s original ID, but the one returned by getMainComponentAsync has a new different ID.
Repro steps:
- Create a new Design document with some frame layers
- Use a plugin to check currentPage.children to verify that the root layers match between Layers list and what’s returned by the API
- Add animations to any layers, open timeline, and make sure you have a layer containing animations selected
- Check currentPage.children to verify that the selected layer’s tree now has a duplicate with a new ID, not visible in Layers list
- Close the timeline and check currentPage.children to verify the duplicate is gone
I couldn’t find any information on whether this is intended behaviour (which I doubt). The issue with instance-component references is preventing me from simply filtering out the duplicates by ID.
