code-connect icon indicating copy to clipboard operation
code-connect copied to clipboard

Bug in React children handling textContent

Open vjeux opened this issue 1 year ago • 4 comments

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.

vjeux avatar Oct 12 '24 00:10 vjeux

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.

ptomas-figma avatar Oct 15 '24 18:10 ptomas-figma

Awesome thank you for confirming this is a real issue!

vjeux avatar Oct 15 '24 22:10 vjeux

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

ptomas-figma avatar Oct 22 '24 13:10 ptomas-figma

Thank you!

vjeux avatar Oct 22 '24 14:10 vjeux