figma / code-snippet-editor-plugin

Translate component variants, properties, and more into dynamic code snippets for your design system.
https://www.figma.com/community/plugin/1311777988952403297/code-snippet-editor
MIT License
126 stars 11 forks source link

[Bug] Hidden nodes generating templating #38

Closed ericandrewscott closed 4 months ago

ericandrewscott commented 5 months ago

In our design system, we have lots of different configurations of items, and designers sometimes often hide layers in certain variants where that configuration is not applicable. Should the templating system take into effect whether nodes are not visible before generating markup for those hidden nodes?

jake-figma commented 5 months ago

just to clarify, this would only happen when rendering children, so the bug is to not render figma.children if they are invisible? that feels like a good default to me. and ill mark this as a bug. should be a one liner

ericandrewscott commented 5 months ago

@jake-figma yep that’s exactly what I meant and what I was thinking! It’s Eric from Expedia by the way 👋

ericandrewscott commented 4 months ago

@jake-figma I forked and started working on a PR and found something interesting that leads me to believe that there might be a Dev Mode bug.

I would expect that a hidden node doesn't even make it into Dev Mode, because the designer's intent is basically that it doesn't exist at all for dev, or at the very least, that the visible attr on the node in Design Mode ends up coming through. Did I find a legit bug? I brought this up on the Friends of Figma Discord and also asked on our Slack channel that TJ, James, and Connor are a part of.

jake-figma commented 4 months ago

@ericandrewscott unsure what youre running into but im not able to reproduce what youre saying. the fix i pushed for this bug works and checks visibility. invisible nodes are visible: false in the plugin api in dev mode, though they are shown in the sidebar. If you try and click them in the sidebar they select the parent. Its a good thought that we should indicate they are hidden similarly to how they are in design mode. if youre still getting this, you should follow up in the slack with the team.

ericandrewscott commented 4 months ago

Yeah I made a screen recording, and then I noticed that it's selecting the parent. I also was going to add them to the Node Params frame, but it totally makes sense that it bubbles to the parent, and that's not necessarily helpful information since clicking them in the sidebar actually selects the parent. Thanks for updating the plugin!