Why we cant originate a action like hide or show component when inside a loop?

Its a genuine question, in my case I am building a custom dropdown that hold a loop of items, I use the show component to change the visibilitiy of the options to true. But is impossible to do the inverse when selecting an option the option list should hide and the button should be visible again, if the hide component is not in a loop it works normally.

Yes its possible to work a way around with a boolean variable for example, but this finction still with a problem

Can you provide screenshots of your set up?

My thought is you could use similar logic to what I used here (for checkboxes) except instead of check/uncheck it would toggle visibility.