Skip to main content
Anima
Apr 16, 2021 6:53 AM UTC

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

10 replies

Gleb
Power Member
Apr 16, 2021 10:09 AM UTC
Active Member
Dec 3, 2022 9:49 PM UTC

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.

Aug 2, 2023 11:36 AM UTC

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
Aug 2, 2023 12:38 PM UTC

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.

Aug 2, 2023 1:09 PM UTC

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

Aug 8, 2023 9:31 AM UTC

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
Aug 8, 2023 9:53 AM UTC

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
Jan 18, 2024 6:44 AM UTC

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
Jan 18, 2024 10:38 AM UTC

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
Jan 18, 2024 10:45 AM UTC

Thanks Gleb,

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

just trying to get it working correctly.