Hi everyone,
I’m not a developer, so I may be missing some details about the API, but I’ve run into what looks like a bug while building a plugin and wanted to share the exact scenario.
I’m creating a plugin that automates different design tasks in the background. Everything was working well until I noticed an issue that only appears when I use figma.on('selectionchange'). I stripped my plugin down to almost nothing, and the problem still occurs as long as that event listener is active.
What’s happening
The bug shows up only under a specific set of conditions:
-
You have a component instance (this does not happen with main components or regular frames).
-
Its width of the frame where the instance is positioned is driven by a variable, and you switch variable modes that change that width.
-
The instance is set to absolute position with left + right constraints.
-
After switching the variable mode, you interact with anything else on the canvas (for example, clicking another instance).
The issue
After the mode change and you click or move other elements (I can replicate it in an easier way if I click a component instance), the affected instance seems to revert to its previous width value, as if it’s inheriting the old variable value before the mode switch. This only happens when the instance is absolutely positioned with left + right constraints. It doesn’t depend on where the second instance is located (the one that trigger the change)—the moment you click another element, the original instance jumps back to the old width.
Because this only occurs when figma.on('selectionchange') is active, it suggests that the selection change event is triggering an unexpected recalculation or update on the instance.
