figma / code-connect

A tool for connecting your design system components in code with your design system in Figma
MIT License
950 stars 68 forks source link

Bug in React children handling textContent #179

Open vjeux opened 1 month ago

vjeux commented 1 month ago

As we are trying code-connect on the internal Meta design system, we ran into an issue with React children handling textContent. We are rendering three children: two figma.instance and one figma.textContent. If all the instances are undefined, then the text shows up just fine. If any of them exists, then the textContent doesn't appear. It looks like a bug, but unclear what is going on.

figma.connect(
 XDSLink,
 'https://www.figma.com/design/qHKLpmJo1s50sJPJLiRM3C/XDS-Web-Library-(Copy)?node-id=52518-22&m=dev',
 {
   props: {
     leftIcon: figma.enum('Show LeftIcon', {
       true: figma.instance('LeftIcon'),
       false: undefined,
     }),
     textContent: figma.textContent('Text Link'),
     rightIcon: figma.enum('Show RightIcon', {
       true: figma.instance('RightIcon'),
       false: undefined,
     }),
   },
   example: props => (
     <XDSLink href="<INSERT URI>">
       {props.leftIcon}
       {props.textContent}
       {props.rightIcon}
     </XDSLink>
   ),
 },
);

Text doesn't appear:

image

Text appears:

image

If we wrap {props.textContent} in <></> then it's always rendering, but it does show the <></> which is not what we want.

ptomas-figma commented 1 month ago

Thanks for reporting. This seems to be a bug on the rendering side where the component "pills" are swallowing the text content. We'll work on a fix and release it in a future release.

vjeux commented 1 month ago

Awesome thank you for confirming this is a real issue!

ptomas-figma commented 3 weeks ago

This should be now be fixed and the text should be rendering in the snippet

vjeux commented 3 weeks ago

Thank you!