Skip to main content
Question

Targeting a layer in an instance associated with a boolean property

  • February 1, 2023
  • 1 reply
  • 542 views

Nathan_Curtis

Need

I would like to target an instance’s layer(s) associated with a boolean prop.

Analysis

The instance includes:

  • A top node with the componentProperties array with boolean props each with a key with an appended {prop name}#{prop id}, such as Help text#3807:17
  • An associated layer that has an id of {instance id}:{library component layer id}, such as I347:39718;3807:28801 yet, as per the API docs, a componentPropertyReferences set to null. This is the node I want to target.

The instance’s .mainComponent property is a reference to:

  • A top component or set node with an id, in this case 119:2895
  • A top node also has componentProperties including Help text#3807:17
  • A corresponding layer associated with the prop with an id, in this case 119:3091, as well as componentPropertyReferences array including visible: Help text#3807:17

The actual variant resides in a separate library file, and includes:

  • A top node with id 3807:27735 and componentPropertyDefinitions that includes Help text:3807:17
  • A corresponding layer with id of 3807:28801 and componentPropertyReferences that includes visible: "Help text:3807:17".

Problem

  • The instance’s .mainComponent layer id doesn’t match the instance’s layer id., which means I can’t use information in the .mainComponent to target that instance’s layer.
  • The instance’s layer id DOES match the actual variant via their ids (3807:28801), which can be mapped within the actual variant by matching the prop definition of 3807:17.

However, I don’t know how to access the library file programmatically, so I can’t get to these matches. Using importComponentByKeyAsync loads the component locally (which I’d like to avoid) and results in different layer ids anyway, defeating the purpose.

Is there a different way other than mimicing the traversal (from the main component’s layer to the top, then down the same path in the instance) to more directly target a layer in an instance associated with a boolean property?

1 reply

Nathan_Curtis

Miraculously, this is resolved by an update a week later…

figma.com – 6 Feb 23

Reply


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