Losing keyboard focus on mouse click

I think its still relevant for many developers I found a solution and verified that it works in production. Hopes it will save a lot of time for somebody