Skip to main content
Question

Selectchange event not updating selection node types


Lewis_Healey

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);
});

3 replies

tank666
  • 4873 replies
  • July 25, 2022

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.


Lewis_Healey
  • Author
  • New Participant
  • 14 replies
  • July 26, 2022

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


tank666
  • 4873 replies
  • July 26, 2022

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.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings