Height of component doesn’t change after hiding layer

Hi all,

I’m stuck with a problem you can hopefully help me with. I have a component that has several booleans of turning things off and on (see image).

However, the component doesn’t shrink when I turn of both bottom items (text description and attachment. It does shrink when I only remove the description to the height including the attachment icon. I did try several settings and hug on the outer container doesn’t solve the problem. Any ideas?

Is it possible that the boolean for show Description is linked to the Text Layer and it’s inside another layer? Figma treats text layer visibility a little different, and even if the layer above it is set to Hug vertically, it will keep the same size…

Description (←Layer)
↳ [T] Description lorem ipsum (←Text Layer)

If you link the “Show Description” Boolean to the Layer, not the Text Layer, it should work like you’re expecting.

Hey Bauke,

Thanks for thinking with me. Both description and attachment icon are in a layer that autolayout’s them horizontally. But we want to be able to turn the visibility off separately or together. We now set a boolean on the ‘mother layer’ that contains both components as well, but it feels a bit hacky altogether.

I managed to replicate it!

It’s a weird Figma bug for sure. I thought it had to do with Figma having trouble with the text layer visibility, but it’s actually the layer above it (The one that contains a text layer) that messes up.

It looks like a layer containing a hidden text layer AND another invisible layer (In your case the attachment icon) with both the text layer and the icon set to invisible will retain the height of the text layer

EDIT: It doesn’t need to be a hidden text layer, it also happens when a layer is empty or contains only hidden objects. For some reason it won’t set its height to 0. But if you nest it in one more layer and hide THAT layer, it works…

Now…
In your case: Would you ever show the Attachment icon without the Description?

Your screenshot shows a truncated headline, so I was assuming you’d never really have a situation where the attachment icon shows without a description.

If so, it makes sense for the whole Layer that contains both the text and the icon to be hidden. And, as a bonus, your instance would only show the boolean switch for the attachment icon when you turn on the description layer. (Good for when other designers use your component :slight_smile: )

If they need to show independently the solution is to use variants:

  • One with the text and the Icon
  • One with only the icon

If you name the variants “Show Text: False” and “Show Text: True” it will behave in the exact same way, showing a switch.

Assign the boolean to the icon like you did before.

It’s not very elegant… But it behaves like you think it should.