Add some API that works as native "Go to main component" menu item

Hi everyone.

I have a custom implementation and it does the thing.

function goToNode(pageId: string, nodeId: string) {
  if (!pageId || !pageName || !nodeId) {
    return;
  }

  const page = figma.getNodeById(pageId) as PageNode;
  if (!page) {
    // Some error handking.
  }

  const node = figma.getNodeById(nodeId) as SceneNode;
  if (node) {
    figma.currentPage = page;
    page.selection = [node];
    figma.viewport.scrollAndZoomIntoView([node]);
  }
}

But recently I’ve discovered that this implementation is useless in case of remote components. First of all it’s impossible to acquire the page since Figma API doesn’t expose full tree of remote componens (component is hanging in a vacuum with undefined parent property). Moreover figma.viewport.scrollAndZoomIntoView() call doesn’t work as expected. It scrolls to the middle of the nowhere on the current page in the current project.

Is there any workaround to make a navigation to a remote component (like native “Go to main component” menu item does)? I understand that Figma API has a lot of security consideration, but If i’m not mistaken navigation to some component in another library doesn’t imply any security riks.

@Gleb, please take a look :wave:

This is currently not possible. Without knowing the fileKey, you can’t even link to the remote component.

Please don’t ping me for every occasion, I do this for free