Issue with setPositionInViewport

I fixed it by clamping the output position…
I find if the output position is bigger then viewport size + 50px or smaller -50px then something happens to the widget and it dissapears…

My solution is probably not ideal but it works for now…

Any comments?