Skip to main content
Question

SelectionChange not firing

  • October 13, 2023
  • 1 reply
  • 348 views

Akshat_Sharma1

I was designing a plugin, where one could click on a selected object and show all its properties onto the same figure. I want to dynamically change selection once user clicks any other shape but i have problem figuring out why my Figma.on not working.

Here is the code:

function runplugin() {
  let selectedElements = figma.currentPage.selection;

  if (selectedElements.length === 0) {
    figma.closePlugin('No elements selected');
    return;
  }

  if (selectedElements.length > 1) {
    figma.closePlugin('Please select one element');
    return;
  }

 console.log('hello');
}

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



figma.closePlugin()

Code is changed to debug. Please Help

1 reply

tank666
  • 4856 replies
  • October 13, 2023

Firstly: the runplugin function is not called anywhere in your code.
Secondly: the plugin closes immediately after launch due to the last line.


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