Nable to get the height and width of the panel

You could try to listen for the resize event on your outer container, instead of on the window.
In theory, the resize event should fire for each element once it’s rendered by UXP, as Kerri explained here