bridge icon indicating copy to clipboard operation
bridge copied to clipboard

Compiler: no way to set properties of exposed nested instances (exposedInstances) — Choice Card labels unreachable; unknown property keys are skipped silently

Open deriazjulien opened this issue 2 months ago • 0 comments

Summary

Figma lets a component expose a nested instance (isExposedInstance: true) so that consumers set the nested instance's properties (its Label, Checked, …) directly from the parent instance's property panel. The Plugin API surfaces this via instance.exposedInstances[], each with its own componentProperties / setProperties().

The Bridge compiler (7.3.1) has no way to reach those properties from a scene graph: INSTANCE.properties is emitted as findPropKey(compSet, prefix, type) + instance.setProperties(...) on the top-level instance only, and exposedInstances is never referenced anywhere in lib/compiler/. Components that follow the "wrapper + exposed atom" pattern therefore cannot be labelled at generation time.

Reproduction (real DS component)

Forms/Choice Card — a clickable card wrapping a Forms/Radio or Forms/Checkbox:

componentPropertyDefinitions (set):
  Control : VARIANT (Radio, Checkbox)
  Checked : VARIANT
  State   : VARIANT

defaultVariant children:
  Forms/Radio  INSTANCE  isExposedInstance: true
    componentProperties: Label#11774:182 (TEXT), Show label#11298:90 (BOOLEAN), Checked (VARIANT), State (VARIANT)

Scene graph attempt:

{ "type": "INSTANCE", "name": "Option1", "component": "Forms/Choice Card",
  "variant": { "Control": "Radio", "Checked": "False", "State": "Default" },
  "properties": { "Label": "Option A" } }

→ compiles (exit 0, no diagnostic), but at runtime findPropKey(comp_forms_choice_card, "Label", "TEXT") returns undefined (the set has no Label), the if (k_Label) guard skips the call, and the card keeps its default label. The failure is silent.

The only Plugin API path is:

var opt = set.defaultVariant.createInstance();
var atom = opt.exposedInstances[0];           // the exposed Forms/Radio
atom.setProperties({ "Label#11774:182": "Option A" });

Proposal

  1. Scene graph syntax for exposed-instance properties, e.g.
    "exposed": [ { "match": { "name": "Forms/Radio" }, "properties": { "Label": "Option A", "Show label": true } } ]
    
    or a path form inside properties: "Forms/Radio.Label": "Option A" / "@0.Label". Codegen: inst.exposedInstances.find(...) + findPropKey against the exposed instance's componentProperties (prefix before #), then setProperties.
  2. Diagnostic instead of silent skip: when a properties key matches no definition on the set, emit RESOLVE_PROPERTY_NOT_FOUND (error or warning) with the available keys — including, if implemented, the exposed instances' keys. Today an unknown property key compiles cleanly and does nothing.

Happy to send a PR for (2) right away and (1) if you agree on a syntax.

deriazjulien avatar Sep 08 '26 13:09 deriazjulien