Scrollbar is present when there is nothing to scroll

I have UScrollBox and some widgets in it. And issue is scrollbar does not disappear when there is nothing to scroll in this UScrollBox. The way I do it is showing and hiding lists of widgets by changing visibility. If switching from the long list with scrollbar to a short list which doesn’t need scrollbar, scrollbar wouldn’t be removed from the screen. Scrollbar is totally inactive, there is no way I can interact with it.
Why is this happening and what could be the reason?

That’s likely because you have the visibility set to hidden. You want to set it to collapsed.
Hidden and collapsed both hide the widget, but hidden keeps the layout the same while collapsed acts as if there’s nothing there.

As you say I use Collapsed to hide widgets. I also noticed that the scrollbar will be hidden as it should be if there was scrolling right before the content changes. That is, if you switch the content right while the content is scrolling in the scrollbox, then in this case the scrollbar will disappear as it should. Otherwise, the content is completely placed in the scrollbox and does not go out of bounds, but the inactive scrollbar remains from the previous state of the scrollbox.

I tried calling UScrollBox::InvalidateLayoutAndVolatility(). Also tried UScrollBox::SetScrollBarVisibility(Collapsed). All this had no effect. And if changing the visibility of the scrollbar does nothing, then it makes me assume that there is no scrollbar as such and this is some kind of rendering defect. Is this possible, and if so, what can be done about it?

I’m not completely sure what’s happening.
You should be collapsing the children of the scroll box, not the scroll bar/box itself. The visibility of the ScrollBox’s scroll bar will update on it’s own.

Okay, let me give you more details.
I have UScrollBox. It contains 5 different widgets. Some of them completely fit into the available space, and some require scrolling. Switching between them occurs at the touch of a button. When the button is clicked, the widget corresponding to it is made visible, and all the others are hidden using ESlateVisibility::Collapsed. This is some kind of menu. The problem is that if the currently displayed widget requires a scrollbar, then when switching to another one that does not require scrolling, the scrollbar itself will remain on the screen in the same position as it was. At the same time, you cannot interact with it, neither scroll, nor something else.

Do you have always show scrollbar disabled?

Yes, always show scrollbar is set to false. I came to a hack solution and change the visibility of the scrollbox to Collapsed and then back to Visible and after that the scrollbar disappears.
But I would like to understand the real reason for this behavior of the scrollbar.