tokens-studio / figma-plugin

Official repository of the plugin 'Tokens Studio for Figma' (Figma Tokens)

Home Page:https://www.figma.com/community/plugin/843461159747178978

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Changes not applying to nodes

cuserox opened this issue · comments

Describe the bug
Given a set of composition tokens to apply to a component, when applying, errors when setting certain characteristics means the changes are not applied

To Reproduce
Steps to reproduce the behavior:

  1. In the tokens tab, apply a different brand to the button (or any component)
  2. See not all the changes on the button (or any component) have been applied

Expected behavior
Composition tokens to be visible on the component

Screenshots or Screencasts
Original thread

Why is happening?

  • The method setValuesOnNode() runs, which applies all relevant values to selection, page, or whatever is chosen
  • Sequence of apply* goes like: applyBorderValuesOnNode, applyBorderRadiusValuesOnNode... if these fail, it gets caught at the end, thus not applying any other values (i.e. applyColorTokenOnNode) lower down
  • A variety of border related references are not being fully resolved, such as ({density.dimensions.interaction.border-radius.sm}, {density.dimensions.interaction.focus.border-width}, density.dimensions.interaction.focus.border-width, etc)
  • The ⚠️ error ⚠️ actually comes from applyBorderRadiusValuesOnNode() where values.borderRadius is still referencing an alias, hence causing NaN

See the width value is also referencing an alias:
Screenshot 2024-06-21 at 11 59 32

Where is this happening?

In production, and also in RC8 (pre v2 release)

🧐 Questions to answer

  • Why are the border attributes not being fully resolved?
  • Is it preferred to not fail the full chain when applying values to nodes? Apply what is ✅, warn about failures ⚠️

Video attached of it occurring in production:
https://github.com/tokens-studio/figma-plugin/assets/114073780/7970c2a7-904c-4fb2-b7f9-f4637884f225

Consensus & summary

  • Paired with @SamIam4Hyma (in this Figma file) to see that the NaN error no longer exists in RC8 (as we had all the tokens referenced correctly!)
  • However, other errors surfaced around Typography, like so:
{
 "message": "in set_textDecoration: Cannot write to node with unloaded font \"FK Grotesk Neue Regular\". Please call figma.loadFontAsync({ family: \"FK Grotesk Neue\", style: \"Regular\" }) and await the returned promise first."
},
{
    "message": "in set_paragraphIndent: Cannot write to node with unloaded font \"FK Grotesk Neue Regular\". Please call figma.loadFontAsync({ family: \"FK Grotesk Neue\", style: \"Regular\" }) and await the returned promise first."
}

🐛Created a ticket to tackle

Aim

Surface friendlier errors to the user when Apply to X doesn't work