tokens-studio / figma-plugin

Official repository of the plugin 'Tokens Studio for Figma' (Figma Tokens)
https://www.figma.com/community/plugin/843461159747178978
MIT License
1.32k stars 190 forks source link

2.0: Token set tree reorder issues #2915

Closed six7 closed 1 week ago

six7 commented 1 week ago

We've received reports from @SamIam4Hyma (so far only from Sam), that our tree is more broken in 2.0 than it is in production. We should look into if those issues are fixable, or if they require a full-on replacement of our tree (eg with react-arborist as we're using that in Studio). If the problems are not fixable, let's not do the full-on replacement just yet, but treat this like a spike of what's required to do so and write down a game plan (because the tree is fairly complex).

The issues happen when you have a deeply nested structure and can be easily reproduced.

Now reorder those sets a few times, like so:

https://github.com/tokens-studio/figma-plugin/assets/4548309/632921e9-689a-4d07-8842-050e7d359d49

The issue seems to have to do with token sets having the same name as token folders. Which is something that can definitely happen, as you can have a tokens folder as well as tokens.json file.

It seems like the token set reorder doesnt work as expected (it's expected that it only works on 1 level, but in this case it makes it appear like some token sets are now children of primitives when in fact we only changed the ordering.


Notes for engineering:

Entry point for the set tree: packages/tokens-studio-for-figma/src/app/components/TokenSetSelector.tsx (which renders the overall tree and modals) which renders packages/tokens-studio-for-figma/src/app/components/TokenSetTree.tsx (which is responsible for the custom reorder logic we implemented) which renders a ReorderGroup as well as packages/tokens-studio-for-figma/src/app/components/TokenSetTree/TokenSetTreeContent.tsx which is responsible for rendering the items