Expose missing fields from the API

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
3 Likes
1 Like

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.

1 Like

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.

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.

1 Like

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

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!

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.

1 Like

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);

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

Thanks Gleb,

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

just trying to get it working correctly.