Skip to main content
Solved

How to set selection for a page


My plugin UI currently displays a bunch of layers & instances. When I select a layer in my UI, I want to zoom in to the page and highlight the layer with selection controls like so:


Before: I’m currently at Web Mobile page and I select “Wedding Bands” which is in Web Mobile


After: I’ve navigated to Web Mobile page, and I’m selecting the “Wedding Bands” layer in Figma

I’m able to jump to my target by setting Figma.currentPage, but I can’t figure out how to set the selection via code. I tried reassigning the current page selection with a new SceneNode like so:

but that doesn’t seem to work. Which is confusing because the documentation seems to say that reassigning is the way to go:

In that case, how do I set a page’s selection to my input selection of nodes?

Best answer by Gleb

figma.currentPage.selection = [ yourInstanceNode ]

View original
This topic has been closed for comments

3 replies

Gleb
  • Power Member
  • 4706 replies
  • Answer
  • August 2, 2023

figma.currentPage.selection = [ yourInstanceNode ]


  • Author
  • 30 replies
  • August 4, 2023

I was looking through my code again and realised that I actually forgot to pass node ids to code.ts, and assigning an array of nodes actually worked fine! Sorry for the false alarm 😓


  • 0 replies
  • August 7, 2023

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.


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