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