Hide One Button, make other button visible

I found another weird thing. There is a Border (name - Sidebar Panel) containing these elements (refer attached image). If I put the buttons out of the Border (Not in the hierarchy, but in the design), they behave even more weirdly. Look below, Watch full video, and try to understand the behaviour -

The close button can disappear just after one click, only if the the Open button is visible. If it’s hidden, I’d have to click two times to make the Close button disappear. It’s kinda hard to explain just watch the attached video again please.