Dynamically create element if collection field isn't empty

Your code looks quite complex whereas this is pretty much what you want from your description I think:

Obviously change the elements involved as you need them but this principle should work for your needs!

Just remember Show/Hide = the space on your page will be the same regardless, either content or empty space, the button is still there but hidden.
Collapse/Expand = the space taken by the element will disappear when collapsed and this is what you are using in your current code, so it should work as long as you’ve set the space of the site where the buttons are (section, container, repeaters etc) to be “auto” or a “max/min” (so they’ll adjust with the collapse/expand) and that depends on your page design. Otherwise you’ve told that space to be “x height” regardless of the content inside it. You can also set your element to be collapsed in the editor as mentioned in the linked answer rather than coding it to be collapsed.

Hopefully that’ll get you on your way to a nice solution! :slight_smile: