After showing/hiding mose cursor can't focus on widget

I found this problem in bug list at 4.8, but in 4.9.1 i still having problem with this. May be i’m doing something wrong?
P.S. If i deleting Input mode, then nothing’s changing

with this script UI loose focus

with this works perfect(one problem cursor not hidden)

How fix this?