Selectchange event not updating selection node types

Hey there! I am making a plugin that’s listening to selection changes and running functions based on the node type, but when I group two text nodes the node type is a GroupNode, which is right, but then I add auto layout and the group stay a GroupNode. The strange thing is that when I reload my plugin and re-select the group, it now says it’s a FrameNode.

Is there a reason why the node type is not being updated through the function? Am I missing something somewhere? The select change documentation is so sparse that it’s hard to know what can be done, thanks


See below for the function that activates the console.log screenshot

figma.on("selectionchange", () => {
  console.log("figma.currentPage.selection", figma.currentPage.selection);
});

I can guess that Figma somehow caches the node ids within the plugin session. You can check that GroupNode and FrameNode have the same id.

I thought that too but the Figma DOM updates for any other node type apart from GroupNode e.g Rectangle => Frame. I wonder why the update doesn’t happen for a Group => Frame conversion

RectangleNode doesn’t turn into FrameNode. The frame wraps a rectangle, i.e. creates a new node where the rectangle is the child of the frame. You can still check their id.