Skip to main content
Anima
April 16, 2021

Expose missing fields from the API

  • April 16, 2021
  • 10 replies
  • 1134 views

There are some fields that we would love to get included from the API, I know there’s a lot of data, but maybe we can add a list to vote between the most relevant ones. I feel that some missing fields make unusable the ones that you expose, for example:

  • Constraints details contain the horizontal and vertical attributes but does not contain the option if the position is fixed when scrolling
  • For reactions, although not documented, the API supports ON_KEY_DOWN, but does not specify which Key

10 replies

Gleb
Power Member
April 16, 2021
Active Member
December 3, 2022

Someone in Figma has a quite different type of brain to invent things like numberOfFixedChildren()

It took 5 minutes for me to understand what does it mean.

August 2, 2023

Isn’t the description of this property misleading?

It should say: “return the number of children which have a fixed position”

It’s not clear to me how to get the children that are fixed.

Gleb
Power Member
August 2, 2023

Yeah seems like the description could be better.

Fixed children are always first in the list so to get all fixed children you need to get the first X children, where X is the number of fixed children.

August 2, 2023

Thanks Gleb. It’s impossible for devs to know that children nodes are placed hierarchically according to their scrolling properties.

August 8, 2023

HI @Gleb, it looks like it’s actually the contrary: the fixed children are the last of the list. Could you confirm this? Thank you!

Gleb
Power Member
August 8, 2023

Figma is quite weird in that regard. Layers that are the first in the UI are gonna be the last in the children array in the API. This can further be affected by the stacking order setting in the Auto Layout layers. In my previous response I didn’t consider this issue and was referring to how things are in the GUI instead of the API. So you are correct.

James_Lawrie
Active Member
January 18, 2024

So is there a way then to actually fix a frame in Figma plugin api? As i am creating a new frame and need to fix it so it wont scroll.

let numberOfFixedChildren;

const newFrame = figma.createFrame();
newFrame.name = "newFrame";

 // Align newFrame to the top left of parentFrame
newFrame.x = 0;
newFrame.y = 0;

const imageNode = figma.createImage(imageData);

// Append the new grouped text to the frame
newFrame.appendChild(imageHolder);

// Append the new frame to the parentFrame, not the page
parentFrame.appendChild(newFrame);
Gleb
Power Member
January 18, 2024

This is a property of the parent frame, not of the object that is being fixed. So to do it, you need to change the container/parent frame property.

container.insertChild(0, newFrame);
container.numberOfFixedChildren = 1
James_Lawrie
Active Member
January 18, 2024

Thanks Gleb,

parentFrame.insertChild(0, newFrame);
parentFrame.numberOfFixedChildren = 1;

just trying to get it working correctly.