tokens-studio/figma-plugin

After importing variables from figma, remote update is not triggered while using genericVersionedStorage

kibbon opened this issue · 4 comments

Token studio v2.0.3 / Figma 124.3.2

Describe the bug
Total 3 bugs:

  1. Import variables from figma, don't triggle updating to remote while using genericVersionedStorage -> expect triggled as usual.
  2. Export variables sets generate WRONG set name and mode name.
  3. Import variables changes list unchanged token.

To Reproduce
Steps to reproduce the behavior:

  1. Open empty figma file, use any genericVersionedStorage setting with a empty token json file
  2. Add variables in figma like this:
    image
  3. Click import variables in token studio:
    img_v3_02ej_fa720166-9420-49a0-adb3-8b125579fc5g
  4. Click export variables in token studio, the generated variables set and mode name is wrong:
    img_v3_02ej_46145e3f-9245-42b3-b99c-fba83cf46c6g
    img_v3_02ej_077bc3f4-d864-4797-ae1d-d6bedfe3cb7g
    As mentioned in Bug 2, the variable set name and mode name are all full name.

Expect: Name the set as 'Color/ColorGroup', modes as 'Dark' and 'Light', generate 1 collection with 2 modes instead of 2 collections

  1. Click import variables in token studio again, we can see that the bad effect of wrong collection name:
    img_v3_02ej_94dec519-3cce-4ef3-a3fa-6ded6dd59a2g
    There is NO WAY to change our collection name again, as it's legal in figma variable system, so we need token studio to support it.
  2. After we temporarily adjust the names of collections and modes, we changed the value of variable color, and try import:
    img_v3_02ej_e73aad6c-47b8-41f8-b95e-45043fa9aa4g
    As mentioned in Bug 1, the value of the changed token is updated, but the "updating generic remote" toast didn't show, and no update request is sent to the remote end.
    If we click "Apply to selection" or add/remove/edit token, it would update as usual.

Expect: "Import variables" should triggle updating.

  1. Import variables again, we saw changed list contained unchanged tokens:
    img_v3_02ej_f7053eec-a6ad-4dca-9e5e-c9a0145bb85g

As mentioned in Bug 3, unchanged token value should be hidden.

Expect: List changed token only.

Tasks

No tasks being tracked yet.

Please note this issue

Hey @kibbon, just to confirm, you're importing variables then exporting them back to keep them in sync. This however is expected behaviour with importing and exporting because of the way the plugin translates them.

When importing variables, the plugin translates Figma modes and collections to sets and subsets. Your Color/ColorGroup collection was imported as the set with its modes as sub-sets Light & Dark. So it doesn’t involve themes. Exporting on the other hand involves themes-groups and themes or if you're not a Pro user then sets that are translated to figma collections and modes. So your set Color/ColorGroup with sub-sets Light & Dark were translated to two different collections with 1 mode each.

Due to these differences in functionality you can’t use both to keep them in tokens/variables in sync. We usually advise users to stick to one flow. So if you’re importing variables then you stick to this flow because it’s the best way of keeping changes in sync, and if you’re exporting you want to stick to this flow. There is workaround for using both to keep tokens & variables in sync but it’s extremely fragile and unreliable.

However, here's the ticket for a feature on our feedback platform FeatureBase, that if implemented can possibly resolve the flow of using both functions to keep variables in sync.

Hey @kibbon, just to confirm, you're importing variables then exporting them back to keep them in sync. This however is expected behaviour with importing and exporting because of the way the plugin translates them.

When importing variables, the plugin translates Figma modes and collections to sets and subsets. Your Color/ColorGroup collection was imported as the set with its modes as sub-sets Light & Dark. So it doesn’t involve themes. Exporting on the other hand involves themes-groups and themes or if you're not a Pro user then sets that are translated to figma collections and modes. So your set Color/ColorGroup with sub-sets Light & Dark were translated to two different collections with 1 mode each.

Due to these differences in functionality you can’t use both to keep them in tokens/variables in sync. We usually advise users to stick to one flow. So if you’re importing variables then you stick to this flow because it’s the best way of keeping changes in sync, and if you’re exporting you want to stick to this flow. There is workaround for using both to keep tokens & variables in sync but it’s extremely fragile and unreliable.

Thanks for your reply! Therefore, the imported and exported collections correspond to the same collection, which is expected under the current token studio plug-in design? From a user perspective, we still hope that this problem will be solved in the future. Until then, I would advise colleagues in our company not to try to use the export function.
In addition, this issue still reports two other bugs, including diff change display exception and import not triggering remote side update. Please pay attention to these two issues.