before:
now:
I've printed Layout.preferredHeight and it was -1. Not setting the height at all also worked but I wasn't sure if that might have any impact if !visible.
Layout.preferredHeight
height
!visible