Focus to viewport when clicking outside widget

Hi guys I have issue where I have my keyboard/gamepad focus properly set into widget.
However when I click anywhere outside the widget then my focus shifted to viewport.
How to prevent this? Searching whole day can’t find working solution. Changing the canvas to visible and whatnot is not working.
Thank you.