In the working example, it works because the content is added directly under the rootVisualContainer, which is set to take all the available space.
In the broken example, it doesn't work because a VisualElement named main-container is introduced as the "root" and is not set to grow. Setting the flex-grow to 1 on that element will give the expected result.